water Posted September 12, 2009 Posted September 12, 2009 (edited) Hi AutoIt and Word gurus,I have a strange problem with word and word.au3 and would very much appreciate your help I use the following code to print word documents to a printer driver that generates PDF-files:expandcollapse popupFunc _Word2PDF($File) Dim $WordExists = False ; Words not running yet If ProcessExists("winword.exe") Then $WordExists = True ; create MS Word application $oWordApp = _WordCreate("") If @error then _ShowError("_WordCreate Error") ; Close empty document $oDoc = _WordDocGetCollection ($oWordApp, 0) _WordDocClose($oDoc,0) $oWordApp.Options.WarnBeforeSavingPrintingSendingMarkup = False $oWordApp.Options.UpdateLinksAtOpen = False ; open document $oDoc = _WordDocOpen($oWordApp,$file,0,0,1) If @error then _ShowError("_WordDocOpen Error") $oWordApp.Activedocument.Subdocuments.Expanded = True $oWordApp.Activewindow.View.ShowRevisionsAndComments = False $oWordApp.Activewindow.View.Type = 3 ; delete PDF file FileDelete($PDFverzeichnis & " " & $InName & ".PDF") ; print document _WordDocPrint($oDoc,0,1,-1,1,$PDFDrucker,0,"","","",0,0) If @error then _ShowError("_WordDocPrint Error") ; close document, don't save changes _WordDocClose($oDoc,0) If @error then _ShowError("_WordDocClose Error") ; close MS Word application If Not $WordExists Then _WordQuit($oWordApp) If @error then _ShowError("WordQuit Error") EndFuncI have several documents that print fine. But one document with 174 pages gets the page numbering wrong. EVERY page has "page 2 of 174". The only difference to the other docs is that this is a master document with one subdocument.The document prints fine when I do it manually.What can I do to force page numbering?I'm running AutoIt 3.3 on Windows XP with Word 2002 GERMAN. Edited September 12, 2009 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted September 12, 2009 Author Posted September 12, 2009 After rearranging the function everything is now working fine Func _Word2PDF($File) $oWordApp = _WordCreate($File) If @error <> 0 then _ShowError("_WordCreate Fehler") $oDoc = _WordDocGetCollection ($oWordApp, 0) If @error <> 0 then _ShowError("_WordDocGetCollection Fehler") $oWordApp.Options.WarnBeforeSavingPrintingSendingMarkup = False $oWordApp.Options.UpdateLinksAtOpen = False $oWordApp.Activedocument.Subdocuments.Expanded = True $oWordApp.Activewindow.View.ShowRevisionsAndComments = False $oWordApp.Activewindow.View.Type = 3 _WordDocPrint($oDoc,0,1,-1,1,$PDFDrucker) If @error <> 0 then _ShowError("_WordDocPrint Fehler") _WordDocClose($oDoc,0) If @error <> 0 then _ShowError("_WordDocClose Fehler") _WordQuit($oWordApp) If @error <> 0 then _ShowError("WordQuit Fehler") EndFunc My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
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