This article has been archived. It is offered "as is" and will no longer be updated.
Custom document properties that are added to a Microsoft Word document by using Automation are not saved after the code calls "Save."
Word does not "dirty" the document when custom document properties are added by usingAutomation. When the document is not dirty, calls to "Save" just return without performing anything.
In the document to which you are adding properties, set the "Saved" propertyto False. This will let Word know the document must be saved.
This behavior is by design.
The following Visual Basic code demonstrates how to add a custom documentproperty and set the "Saved" property to False:
' Launch Word Dim wdapp As Object Set wdapp = CreateObject("Word.Application") ' Make it visible... wdapp.Visible = True ' Open a document... Dim doc As Object<?xm-insertion_mark_start author="v-thomr" time="20070416T123039-0600"?><?xm-insertion_mark_end?> ' In Word 2007, change the document name to testdoc.docx. Set doc = wdapp.Documents.Open("C:\mydocu~1\testdoc.doc") ' Add a custom document property... doc.CustomDocumentProperties.Add "MyProp", False, 1, 123 ' Uncomment this line to let Word know document is "dirty," so it ' will save the new Custom Document Property. 'doc.Saved = False ' Save document doc.Save ' Close Word... wdapp.Quit