dbaron4 Posted November 6, 2015 Posted November 6, 2015 The following script which is supposed to update the Word document file properties (including the calculated page numbers in the document file properties) works in 3.3.12.0 but fails with a COM error in 3.3.14.2. The error I get is 80020006 - Unknown Name:#include <Word.au3> $oWordApp = _Word_Create(1) $oDoc = _Word_DocOpen($oWordApp, "C:\TEMP9\IN\Master - RS15P05 - Notes Summary.docx") $objErr = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler $oDoc.Update ; RESULTS IN COM ERROR 80020006 - UNKNOWN NAME $objErr = 0 ;disable custom error handler Exit Func MyErrFunc() $hexnum = hex($objErr.number, 8) $SQLErr = $objErr.description SetError(1) $msg = "COM error detected!" & @CRLF & @CRLF & _ "Error description: " & $objErr.description & @CRLF & _ "Error windescription: " & $objErr.windescription & @CRLF & _ "Error lastdllerror: " & $objErr.lastdllerror & @CRLF & _ "Error scriptline: " & $objErr.scriptline & @CRLF & _ "Error number: " & $hexnum & @CRLF & _ "Error source: " & $objErr.source & @CRLF & _ "Error helpfile: " & $objErr.helpfile & @CRLF & _ "Error helpcontext: " & $objErr.helpcontext MsgBox(16, "Error", $msg) If IsObj($oDoc) Then _Word_DocClose($oDoc) If IsObj($oWordApp) Then _Word_Quit($oWordApp) Exit EndFunc ;==>MyErrFuncShould the Word document file properties be updated (page numbers recalculated) in a different manner?
water Posted November 6, 2015 Posted November 6, 2015 (edited) Which version of Office do you run? Edited November 6, 2015 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 November 6, 2015 Posted November 6, 2015 I just checked the Word 2010 reference. There is no Update method for the document object. Do you mean the UpdateSummaryProperties method? 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
dbaron4 Posted November 6, 2015 Author Posted November 6, 2015 I checked and I have Word 2013. I tried $oDoc.UpdateSummaryProperties but I then get an error which includes the phrase "command not available on this platform".
water Posted November 6, 2015 Posted November 6, 2015 That's true. On Word 2013 method UpdateSummaryProperties is no longer available.You could activate the macro recorder in Word, do what you need to do manually, stop the recorder and post the resulting VBA code. Should be easy to translate to AutoIt. 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
dbaron4 Posted November 6, 2015 Author Posted November 6, 2015 I am wondering if the UpdateSummaryProperties method was removed because it is no longer needed. As in the properties are always up to date. I am going to test this.
dbaron4 Posted November 10, 2015 Author Posted November 10, 2015 I am posting the resolution to my problem. This code does the job for me:; $oDoc.Update ; Sleep(2000) For $oSR in $oDoc.StoryRanges $oSR.Fields.Update Next Sleep(2000)
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