PRB: Word Fails to Save Custom Document Properties (195425)



The information in this article applies to:

  • Microsoft Visual Basic Learning Edition for Windows 5.0
  • Microsoft Visual Basic Learning Edition for Windows 6.0
  • Microsoft Visual Basic Professional Edition for Windows 5.0
  • Microsoft Visual Basic Professional Edition for Windows 6.0
  • Microsoft Visual Basic Enterprise Edition for Windows 5.0
  • Microsoft Visual Basic Enterprise Edition for Windows 6.0
  • Microsoft Office XP Developer
  • Microsoft Office 2000 Developer
  • Microsoft Word 2002
  • Microsoft Word 2000
  • Microsoft Word 97 for Windows

This article was previously published under Q195425

SYMPTOMS

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

CAUSE

Microsoft Word 97, Word 2000, and Word 2002 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
				

Modification Type:MinorLast Reviewed:3/21/2005
Keywords:kbAutomation kbprb KB195425