doc properties

S

Senad Isanovic

Need more information about document properties in Word 2002 (XP) doc file.
(File, Properties, Custom, Add property) How do I programmatically from VBA
add these properties. How can I rename a doc properties? Can one doc
property contain more then one value? There must be some good site where I
can find a more info about this subject. Thanks a lot!
 
D

Dave Lett

Hi Senad,

You can add custom document properties with something like the following:

ActiveDocument.CustomDocumentProperties.Add _
Name:="YourName", LinkToContent:=False, Value:="Value", _
Type:=msoPropertyTypeString

For more reading, you can check out "How to use a single VBA procedure to
read or write both custom and built-in Document Properties" at
http://word.mvps.org/faqs/macrosvba/MixedDocProps.htm

As for having multiple values per property: in theory, I think you can if
the value type is text and THEN you parse that text as an array, but I
haven't tested this.
Ummm just tested it, and it works (there might be maximum length limits for
these values):

Dim sValues
ActiveDocument.CustomDocumentProperties("YourName").delete

ActiveDocument.CustomDocumentProperties.Add _
Name:="YourName", LinkToContent:=False,
Value:="Value1,Value2,Value3,Value4", _
Type:=msoPropertyTypeString
sValues = Split(ActiveDocument.CustomDocumentProperties("YourName").Value,
",")
Debug.Print ActiveDocument.CustomDocumentProperties("YourName").Value
For iCount = 0 To UBound(sValues)
Debug.Print sValues(iCount)
Next iCount

HTH,

Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top