You are currently offline, waiting for your internet to reconnect

Word fails to save custom document properties

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.
More information
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				

Article ID: 195425 - Last Review: 01/12/2015 16:02:06 - Revision: 6.0

Microsoft Visual Basic 5.0 Learning Edition, Microsoft Visual Basic 5.0 Professional Edition, Microsoft Visual Basic 6.0 Professional Edition, Microsoft Visual Basic 5.0 Enterprise Edition, Microsoft Office XP Developer Edition, Microsoft Office 2000 Developer Edition, Microsoft Office Word 2007, Microsoft Word 2002, Microsoft Word 2000, Microsoft Word 97 Standard Edition

  • kbnosurvey kbarchive kbexpertiseinter kbautomation kbprb KB195425