I am using Word VBA and want to store some data in a Collection using two arguments: a Key and some data associated with that key. Here is the code:
' Test storing and retrieving some data.
Dim ACollection As New Collection
Dim KeyData As Variant
Dim ItemData As Variant
' Make up some data: a key and something related to that key
KeyData = "5"
ItemData = "Test"
ACollection.Add Key:=KeyData, Item:=ItemData 'Add items to the collection
' Now try to retrieve that information
Dim MyObject As Variant
For Each MyObject In ACollection
ItemData = MyObject ' half of the information stored is retrieved
Key Data = ?? ' how do I get the Key used in storing the information?
Of course my actual code is a bit more complex. The above just shows the essence of the problem: to retrieve both the data stored and the key used for storing it.
When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …