AutoList Members for CustomDocumentProperties

G

Greg Maxey

The VBA help for CustomDocumentProperties uses an example

Document("Sales.doc").CustomDocumentProperties.Add ....

Why won't the .Add part autolist like it will with:

ActiveDocument.Variables.Add ?

Thanks
 
J

Jezebel

Yhey are different types of object. Document variables are defined within
the Word library (eg Dim x as Word.Variable) -- and the Variables collection
is also defined within Word as a specific type (Dim xx as Word.Variables).

The document property object is defined in the Office library (Dim y as
Office.DocumentProperty) while the collection of CustomDocumentProperties is
simply an object property of a Word document. You can't declare Dim yy as
CustomDocumentProperties, because that type isn't defined anywhere.

In other words, the Word document object has a property,
CustomDocumentProperties, which is just an object as far as VBA is
concerned -- VBA doesn't know what properties or methods that object might
have, so there is no info for Intellisense to work with.
 
G

Greg Maxey

Jezebel,

After looking at the object browser I figured something along your line.
This probably helps explain why you can very easily add a varialbe

ActiveDocument.Variables("myVar").Value = "Test1"

but not

ActiveDocument.CustomDocucmentProperties("myVar").Value = "Test1"
 
G

Greg Maxey

Jezebel,

After looking at the object browser I figured something along your line.
This probably helps explain why you can very easily add a varialbe

ActiveDocument.Variables("myVar").Value = "Test1"

but not

ActiveDocument.CustomDocucmentProperties("myVar").Value = "Test1"
 
J

Jezebel

I think that's right. Variables is an object as such, which includes an
'auto add' method -- CustomDocumentProperties is simply a collection, and
thus does not.
 

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