Article ID: 212724 - View products that this article applies to.
This article was previously published under Q212724
In Microsoft Word, you can use Microsoft Visual Basic for Applications to access the summary information in the Properties dialog box (on the File menu, click Properties) and then display the information in a message box, insert the information into the active document, or store the values within a variable.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To retrieve or set values on the Summary tab of the Document Properties dialog box, use the following literal string arguments or property constants with either of the two methods below.
Method 1: Use the BuiltInDocumentProperties PropertyUse the BuiltInDocumentProperties property to set and return summary information for the active document. You can specify which value to set or retrieve by referencing the argument through a built-in constant or a literal string. The following sample code uses the wdPropertyTitle constant to retrieve the title for the active document. The result is displayed in a message box.
The following sample code uses a literal string to define the keywords for the active document:
Method 2: Use the Dialogs Property to Set and Return ValuesUse the Dialogs property to set and return values for the active document's summary information.
Before you return or change a built-in dialog box setting, you need to identify the individual dialog box. To do this, use the Dialogs property and a WdWordDialog constant. The following sample code returns the properties Dialog object that refers to the Summary tab.
You can set or retrieve the following literal string arguments without displaying the Summary tab when a document is open.
TitleThe following sample macro retrieves the current value of the Title string, places this value in a variable string, and sets a new value without displaying the Properties dialog box.
The following sample macro sets a new value for Title and displays the Properties dialog box.
For more information about displaying, setting, or retrieving values in Word dialog boxes, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type Displaying built-in Word dialog boxes in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
For more information about how to use the sample code in this article, click the article number below to view the article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/212536/EN-US/ )OFF2000: How to Run Sample Code from Knowledge Base Articles
For more information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
(http://support.microsoft.com/kb/226118/EN-US/ )OFF2000: Programming Resources for Visual Basic for Applications
Article ID: 212724 - Last Review: October 11, 2006 - Revision: 3.2