Problem with Word Document Variables

G

Guest

The Add method for the Document Variables collection is defined more or less
as follows:
expression.Add(Name, Value)
expression: Required. An expression that returns a Variables object.
Name: Required String. The name of the document variable.
Value: Optional Variant. The value for the document variable.

Since Value is a variant, I supposed that I could add a collection to the
variables collection, yet I'm getting a "Type Mismatch" error.
Example code is:
Dim oColl As New Collection
oColl.Add Item:=1, Key:="1"
oColl.Add Item:=2, Key:="2"

ActiveDocument.Variables.Add Name:="oColl", value:=oColl

Can someone help me understand where I'm going wrong?
Thank you.
 
J

Jonathan West

Hi Ches,

The documentation is in error. The Value property of a Variable object is of
type String, and so using the Add method to add to the Variables collection,
the Value parameter must also be a String.

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email
 

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