General discussion

Locked

Word VBA6 programming issue

By Geoff_H ·
I would like to store the results of a Word VBA string function into one of the optional Fields that can be selected either in the Header or Footer. One of File Properties'constants such as "Client" in the "Custom" tab or "Author" in the "Summary" tab would be great but how do I go about programming that?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Word VBA6 programming issue

by DKlippert In reply to Word VBA6 programming iss ...

This from the VBA Editor Help file (use the Object browser to look for CustomDocumentProperties):

Example
This example inserts a list of custom built-in properties at the end of the active document.

Set myRange = ActiveDocument.Content
myRange.Collapse Direction:=wdCollapseEnd
For Each prop In ActiveDocument.CustomDocumentProperties
With myRange
.InsertParagraphAfter
.InsertAfter prop.Name & "= "
.InsertAfter prop.Value
End With
Next
This example adds a custom built-in property to Sales.doc.

thename = InputBox("Please type your name", "Name")
Documents("Sales.doc").CustomDocumentProperties.Add _
Name:="YourName", LinkToContent:=False, Value:=thename, _
Type:=msoPropertyTypeString

Collapse -

Word VBA6 programming issue

by Geoff_H In reply to Word VBA6 programming iss ...

Thanks for your responsiveness. The second solution worked all the time the Property was "missing" though there were run-time errors trying to .Add when the Propety was already there but needed updated. What is the solution to that problem?

Collapse -

Word VBA6 programming issue

by Geoff_H In reply to Word VBA6 programming iss ...

This question was closed by the author

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Software Forums