dbaron4 Posted November 6, 2015 Share 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? Link to comment Share on other sites More sharing options...
water Posted November 6, 2015 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted November 6, 2015 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
dbaron4 Posted November 6, 2015 Author Share 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". Link to comment Share on other sites More sharing options...
water Posted November 6, 2015 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
dbaron4 Posted November 6, 2015 Author Share 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. Link to comment Share on other sites More sharing options...
dbaron4 Posted November 10, 2015 Author Share 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) 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