Microsoft KB Archive/195425

= Word fails to save custom document properties =

Article ID: 195425

Article Last Modified on 4/16/2007

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 6.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 Visual Basic 6.0 Enterprise Edition
 * Microsoft Office XP Developer Edition
 * Microsoft Office 2000 Developer Edition
 * Microsoft Office Word 2007
 * Microsoft Office Word 2003
 * Microsoft Word 2002 Standard Edition
 * Microsoft Word 2000 Standard Edition
 * Microsoft Word 97 Standard Edition

-



This article was previously published under Q195425



SYMPTOMS
Custom document properties that are added to a Microsoft Word document by using Automation are not saved after the code calls "Save."



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



RESOLUTION
In the document to which you are adding properties, set the "Saved" property to False. This will let Word know the document must 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<?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

Additional query words: WD2007

Keywords: kbexpertiseinter kbautomation kbprb KB195425

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.