Jump to content

Recommended Posts

Posted

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   ;==>MyErrFunc

Should the Word document file properties be updated (page numbers recalculated) in a different manner?

Posted (edited)

Which version of Office do you run?

Edited 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

 

Posted

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

 

Posted

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".

Posted

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

 

Posted

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.

Posted

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)

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...