PRB: Word Fails to Save Custom Document Properties

ID: Q195425


The information in this article applies to:


SYMPTOMS

Custom document properties that are added to a Word 97 or Word 2000 document via Automation are not saved after calling "Save."


CAUSE

Microsoft Word 97 or Word 2000 do not "dirty" the document when custom document properties are added via automation. When the document isn't dirty, calls to "Save" just return without performing anything.


RESOLUTION

In the document to which you're adding properties, set the "Saved" property to False. This will let Microsoft Word know the document needs to be saved.


STATUS

This behavior is by design.


MORE INFORMATION

The following Visual Basic code demonstrates how to add a custom document property 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
   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 

Additional query words:


Keywords          : kbAutomation kbVBp kbVBp500 kbVBp600 kbGrpDSO kbOffice2000 kbword2000 
Version           : WINDOWS:2000,5.0,6.0,97; :
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: August 3, 1999