Kohr Posted September 28, 2006 Share Posted September 28, 2006 I am basically trying to use the functions from Word.au3 to replace methods I used before. What I am doing is I would enter text in Word, insert a picture, then insert a PageBreak. This would give me a nice text/picture view for each page in Word. This is represented using the following code.#include <Word.au3> $DefaultPath = "C:\Program Files\temp\" $oWordApp = _WordCreate (@DesktopDir & "\WordOutput2.doc", 0, 0) $oDoc = _WordDocGetCollection ($oWordApp, 0) With $oWordApp.Selection .TypeText ("Text on Line 1" & @CRLF) .TypeText (@CRLF) .InlineShapes.AddPicture ($DefaultPath & "Temp\MWSnap.png", False, True) .TypeText (Chr("12")) EndWith _WordDocSaveAs ($oDoc) _WordQuit ($oWordApp)What I wanted to do is use function _WordDocAddPicture to replace the code ".InlineShapes.AddPicture ($DefaultPath & "Temp\MWSnap.png", False, True)" but I am not exactly sure how to do this. I did notice there is a "range" option to that function but I am having terrible luck using it. When I did get it to work it would insert the picture before any of the text even though I had ".TypeText" before the function (which is probably correct I am just not grasping why).I did look at http://msdn.microsoft.com/library/default....gWithRanges.asp but I guess my knowledge is weak using range vs. selection.Any suggestions would be great. Thanks.Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted September 28, 2006 Moderators Share Posted September 28, 2006 I believe this accomplishes what you are needing. #include <Word.au3> $sPath = @ScriptDir & "\" $oWordApp = _WordCreate ($sPath & "WordOutput2.doc", 0, 0) $oDoc = _WordDocGetCollection ($oWordApp, 0) $oRng = $oDoc.Range With $oRng .Text = "Text on Line 1" & @CRLF & @CRLF .Collapse (0) ;0 = end, 1 = start EndWith $oPic = _WordDocAddPicture ($oDoc, $sPath & "MWSnap.png", False, True, $oRng) With $oPic.Range .Collapse (0) ;0 = end, 1 = start .InsertBreak (7) ;6 = line, 7 = page .Text = "Text on the second page." EndWith _WordDocSaveAs ($oDoc) _WordQuit ($oWordApp) Link to comment Share on other sites More sharing options...
Kohr Posted September 28, 2006 Author Share Posted September 28, 2006 It works perfectly. Thanks again for all your help Big Daddy. Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted September 28, 2006 Moderators Share Posted September 28, 2006 No problem, glad I was able to help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now