Link to home
Start Free TrialLog in
Avatar of JohnRobinAllen
JohnRobinAllenFlag for Canada

asked on

With a VBA Collection (in Word), can I access both the data and the key stored?

Using VBA in Word, if I have stored strings in a collection, each with a different Key, is it possible to go through all the members of the collection and retrieve not only the stored string but also the key that accesses the string?
     The following code displays the strings of data stored inside "MyCollection":
     
     Dim x as Variant
     For each x in MyCollection
         Msgbox x
     Next x

     What I need is something that will also tell me the keys that access those data.

     Thanks!

     j.r.a.
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JohnRobinAllen

ASKER

Each day I am more and more appalled at how little I know about VBA. The Dictionary is the perfect solution for my problem. I am indebted to Matthew for his help.
    j.r.a.
Glad to help :)

The Dictionary is one of my favorite objects.