Sign in to follow this  
Followers 0
Kevitto

.doc File Reading in AutoIT

4 posts in this topic

Hello, I have an issue with my current script and the answer alludes me!

I have a script that reads from a Word file and puts all the content into an html document (generates tags and whatnot), but I cannot find a way to export/save/link to the images contained within the Word document.  I was wondering if there was a way to do this.

Also, same issue with the word comments.  I can't pull those out either.  

I know VBS/VBA might have been a better tool, but I'm used to AutoIT and most of the script was written and working by the time people started inserting pictures and comments into their word documents!

FYI, this is for a script that automatically takes a preformatted word document (containing a wiki-like solution for an internal knowledge base) and converts it into HTML.  This was all done manually before, but I can't be bothered to read/copy 5,000+ documents by hand.

Thank you,

Kevitto

Share this post


Link to post
Share on other sites



Hi, Kevitto. Are you using the built-in Word functions, or some other method? How about posting a reproducer to show what you're doing? Otherwise, we have to guess at what you're doing in your script, and then try to help you troubleshoot ;)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Check the new Word UDF that comes with the latest beta version of AutoIt. Function _Word_DocSaveAs allows to save a document as format $WdFormatHTML.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Sorry, should have included at least part of the function.  Here it is.  I'm basically just opening the word file, reading every line and transposing it into a temp text file in a specific order and then the script makes it into an html page (not included).  I basically can't get tables, images and comments.  it only gets text.

I know it's a bit messy, but I'm working with the knowledge I got :P

Thanks!

$files_array = _FileListToArrayEx($path, "*.doc", Default, "~*")
$oWordApp = ObjCreate("Word.Application")
$all_solutions = ""
If(isArray($files_array)) Then
   For $i = 1 to UBound($files_array)-1
 $oDoc = _WordDocOpen($oWordApp, $files_array[$i])
 $oDoc.Range.WholeStory()
 $oDoc.Range.Copy
 $temp_file = FileOpen("C:\Output\temp.txt", 1)
 FileWrite($temp_file, ClipGet())
 FileClose($temp_file)
 _WordDocClose($oDoc)
 _MakeSolution()
   Next
   _WordQuit($oWordApp)
   MsgBox(0,"Success","Loaded " & UBound($files_array)-1 & " word documents." & @CRLF & $all_solutions)
   ClipPut($all_solutions)
Else
Edited by Kevitto

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0