Hi José,
The problem you had isn't specific to the BuiltInDocumentProperties collection;
it's related to the way VBA addresses specific members of any collection.
All collections have an Item method that returns a member of the collection. The
method takes one argument, which the Help topic calls "index". The index can be
an integer from 1 to the number of objects in the collection; or (for most
collections) it can be a string that was assigned to the member when it was
added to the collection.
As a concrete example, the member of the BuiltInDocumentProperties collection
that contains the document title is the first member, so its integer index is 1.
Its string index is "Title". (The quote marks are required to tell VBA that this
is a literal string and not a variable name.) So each of these expressions would
return the same value:
result = ActiveDocument.BuiltInDocumentProperties.Item(1)
result = ActiveDocument.BuiltInDocumentProperties.Item("Title")
There are other ways to pass an integer or a string to the Item method. For an
integer, you can use a named constant (technically, an "enumeration" value). The
name wdPropertyTitle represents an integer value of 1. Or you can assign a
variable that holds integer values, perhaps to use it in a loop. So these are
equivalent to the first expression above:
result = ActiveDocument.BuiltInDocumentProperties.Item(wdPropertyTitle)
Dim nIndex As Integer
nIndex = 1
result = ActiveDocument.BuiltInDocumentProperties.Item(nIndex)
Similarly, you can use a variable that holds string values, like this:
Dim sIndex As String
sIndex = "Title"
result = ActiveDocument.BuiltInDocumentProperties.Item(sIndex)
In this example, note that the variable name does not have quote marks, but the
literal value does have quotes.
Finally, instead of explicitly calling the Item method as above, you can apply
the index directly to the collection's name as if it was an array. The
expressions above can be written as
result = ActiveDocument.BuiltInDocumentProperties(1)
result = ActiveDocument.BuiltInDocumentProperties("Title")
and so on.
For a reference on this particular point, you can look at "Collection Indexes"
in Chip Pearson's page at
http://www.cpearson.com/excel/optimize.htm or
"Accessing an Item in a Collection" in
http://www.functionx.com/vbaexcel/Lesson08.htm.
--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.