4 posts in this topic
Is there anyway to store word documents in Autoit GUI? For example I have a instruction sheet that I want to bundle up with the exe.
So a user simply clicks the icon and the stored document will launch (Something like how you can add objects like excel sheets in word documents )
(I Know we can launch word files from script directory)
I've failed to find an example of _Word_DocFindReplace which searches for formatted text (I'm looking for stand alone paragraph marks that are formatted other than normal i.e. Bold Italic, Underlined).
The reason being that when converting a Word document to html one of the main problems in the results is that a stand alone paragraph mark is converted to an html space that retains the formatting ...> <... thus showing up as a underline _ in a browser when it should be blank. I've played around with the script and got it to at least un-bold the first paragraph mark regardless if it was bold or not but I'd like to clear all formatting from any stand alone paragraph marks in the whole document. Below is what I've done so far (not much more than in the help file I'm afraid) . Way down at the bottom of the _Word_DocFindReplace help text is this parameter but without any examples to be found :
$bFormat [optional] True to have the find operation locate formatting in addition to or instead of the find text (default = False) #include <MsgBoxConstants.au3> #include <Word.au3> $processing = @MyDocumentsDir & '\AutoIt_code\getter\processing\' Global $oWord = _Word_Create() Global $sTestfile = $processing & "Testing.docx" ConsoleWrite($sTestfile & @CRLF) Global $oDoc = _Word_DocOpen($oWord, $sTestfile) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "ERROR", "Error opening file = '" & $sTestfile & "'" & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oRangeFound = _Word_DocFind($oDoc, "^p", Default, Default) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _ "Error locating paragraph control character in the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) $oRangeFound.Bold = False If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", _ "Error inserting text after the paragraph control character in the document." & @CRLF & "@error = " & @error & _ ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFind Example", "Paragraph control character successfully replaced." & @CRLF & _ "Text inserted in paragraph 2.")
Okay this is likely due to my not properly understanding objects.
I'm using _Word_DocRangeSet to extend a range (in this case to the end of a line).
The issue I've encountered is that extending one range seems to affect another range.
It may be that an object can't be assigned or equated.
In any event the program and test file (place in the same directory) illustrate the issue.
Test 1 - shows the documentation for _Word_DocRangeSet correctly shows how the range is extended and the assigned result is extended. No problem here just part of my learning.
Test 2 - like Test 1 but no assignment of the result from _Word_DocRangeSet is needed. Again correct and my learning.
Test 3 - here is where the issue is. After an assignment to a new object the old one seems to be affected by _Word_DocRangeSet. This I don't understand (perhaps the assignment is really a namespace pool and points to the same structure like aliases <-- wild guess).
Test 4 - shows that using .Select can extend the range and leave the original range alone.
Any hints/pointers on what's going on appreciated.
Test for WordRangeTesting v1c.docx
Okay I've hacked down a large program to illustrate the problem I'm having.
I'm using the built-in Word UDF (which is great) and am finding a range and then copying it to the clipboard and sticking it in an array for viewing.
Then extending the range and again copying it to a clipboard and sticking it into the array.
It seems to drop the ranges randomly. I can't figure out what I'm doing wrong (or if there's a better way to get a range into a variable).
Run the program with the test file and you'll see entries being dropped (put test file in same directory as the program).
Any pointers or help much appreciated.
Hacked down program for testing Range extend and copy v3c.au3
Test for Range Copy v1a.docx