Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

Accessing DocProperty from VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Clark - 13 Jun 2005 14:33 GMT
I wish to do the following, and I am having a hard time figuring out
how from the documentation:

Read the current value of custom DocProperty items from Word VBA(named
MyFormattedDate and MyUnformattedDate)

Update the value of these same DocProperty items from Word VBA

Thanks to all
Chuck - 13 Jun 2005 14:57 GMT
Use
  ActiveDocument.CustomDocumentProperties("MyFormattedDate").Value
to both read and write the value.

You could add some testing code to make sure the variables are in the
document if there's a possibility that they might not be, eg

Dim docProp As DocumentProperty
Dim blnFound As Boolean

blnFound = False

For Each docProp In ActiveDocument.CustomDocumentProperties
   If docProp.Name = "MyFormattedDate" Then
       blnFound = True
   End If
Next docProp

With ActiveDocument

If blnFound = False Then
   .CustomDocumentProperties.Add _
       Name:="MyFormattedDate", _
       Value:="MyValue"
Else
   .CustomDocumentProperties("MyFormattedDate").Value = "x/x/xx"
End If

End With

> I wish to do the following, and I am having a hard time figuring out
> how from the documentation:
[quoted text clipped - 5 lines]
>
> Thanks to all
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.