Santana Posted June 30, 2009 Posted June 30, 2009 Hi guys, I am running into a problem with something I thought was pretty simple. I am working on a script that creates a MS Word document and it needs to change the page orientation to landscape and then insert a image into the page. i thought that by doing Send("!f")..etc after "_WordCreate () " to do the landscape would take care of it but it opens the file menu of the script instead of the doc. I thought that the document takes the focus by default (or at least i think that is what the help file says) but it is not the case with this script. can anyone give me suggestion or a workaround with this issue? I will really appreciate it Thanks in advance Just another special date with a different challenge
lordicast Posted June 30, 2009 Posted June 30, 2009 (edited) I dont know what your looking for but this works great for me. #include <Word.au3> $sPath = @ScriptDir & "\" $file = "AW.JPG" $oWordApp = _WordCreate ('') $oDoc = _WordDocGetCollection ($oWordApp, 0) WinActivate('Document1 - ') WinWaitActive('Document1 - ') send('!p{o}{Down}{enter}') sleep(2000) _WordDocAddPicture ($oDoc, $sPath & $file, 0, 1) While 1 sleep(10) WEnd edited sleep time... Edited June 30, 2009 by lordicast [Cheeky]Comment[/Cheeky]
Andy007 Posted July 4, 2009 Posted July 4, 2009 Hi Santana, Here is another alterative (sorry not the full prg but should help)... ... $wd = _WordCreate("",0,0,0) ; Start invisible. if @error then SplashOff() MsgBox(0,"Error","Unable to start word...") _MyExit() endif if $selected_layout = "0" then $wd.Activewindow.ActivePane.View.Zoom.Percentage = 85 else $wd.Activewindow.ActivePane.View.Zoom.Percentage = 75 endif ; Hide my program now... GUISetState(@SW_HIDE) $wd.DisplayAlerts = -1 $dc = _WordDocGetCollection ($wd, 0) $open_doc_count = @extended ; MsgBox(0, "Document Count", $open_doc_count) $dc.PageSetup.Orientation = $selected_layout; 0 = Portrait, 1 = Landscape $dc.PageSetup.TopMargin = _Convert_CmToPt(1.0) $dc.PageSetup.BottomMargin = _Convert_CmToPt(1.0) $dc.PageSetup.LeftMargin = _Convert_CmToPt(1.0) $dc.PageSetup.RightMargin = _Convert_CmToPt(1.0) Sleep(100) $bmp = _WordDocAddPicture ($dc, $prtscn_file, 0, 1) If Not @error Then $bmp.Range.InsertAfter (@CRLF & @CRLF) ... Regards,Andy (no, the other one)
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