Article ID: 158768
Article Last Modified on 1/19/2007
Literal String Arguments Property Constants ------------------------ ------------------ Title wdPropertyTitle Subject wdPropertySubject Author wdPropertyAuthor Manager wdPropertyManager Company wdPropertyCompany Category wdPropertyCategory Keywords wdPropertyKeywords Comments wdPropertyComments Hyperlink base wdPropertyHyperlinkbase
Sub GetSetDocProps()
If Documents.Count > 0 Then
Dim dp As Object
Set dp = ActiveDocument.BuiltInDocumentProperties
' Retrieve and display the active document's
' title by using the constant "wdPropertyTitle."
MsgBox dp(wdPropertyTitle)
End If
End Sub
The following sample code use a literal string to define the keywords for
the active document:
Sub SetDocProps()
If Documents.Count > 0 Then
Dim dp As Object
Set dp = ActiveDocument.BuiltInDocumentProperties
' Set KeyWords for the active document by
' using a literal string.
dp("KeyWords") = "Summary Information Example Macro"
ActiveDocument.Save
End If
End Sub
Set myDialog = Dialogs(wdDialogFileSummaryInfo)You can set or retrieve the following literal string arguments without displaying the Summary tab when a document is open.
Title
Subject
Author
Manager
Company
Category
Keywords
Comments
Hyperlinkbase
Sub SetSummaryInfo ()
Dim dp As Object
Dim sTitle As String
If Documents.Count > 0 Then
Set dp = Dialogs(wdDialogFileSummaryInfo)
' Retrieve value of "Title" into a variable.
sTitle = dp.Title
' Set "Title" to a new value.
dp.Title = "My Title"
' Set the value without showing the dialog.
dp.Execute
' Save the changes
ActiveDocument.Save
End If
End Sub
The following sample macro sets a new value for Title and displays the
Properties dialog box.
Sub SetSummaryInfo()
Dim dp As Object
If Documents.Count > 0 Then
Set dp = Dialogs(wdDialogFileSummaryInfo)
' Set "Title" to a new value.
dp.Title = "My Title"
' Set the value.
dp.Execute
' Save the changes.
ActiveDocument.Save
' Display the dialog.
' Note: Using the Display method will not keep changes
' manually entered into the dialog box. To keep changes
' manually entered in the dialog box, use the Show method.
dp.Display
End If
End Sub
For more information about displaying, setting, or retrieving values in
Word dialog boxes, click Office Assistant, type "Displaying dialog boxes"
(without the quotation marks), click Search, and then click Displaying
built-in Word dialog boxes.
173707 OFF97: How to Run Sample Code from Knowledge Base Articles
Additional query words: wordcon vb vba vbe
Keywords: kbfaq kbhowto kbmacroexample KB158768