My Win10 has Office 2019 and Visual Studio 2017 Community [updated], and I assume I have the same collection objects as with Win 7. The following now gives an invalid COM Object
]
d = CreateObject("VBA.Collection")
d.Add( "Athens" )
d.Add( "Belgrade" )
d.Add( "Cairo" )
[/font]But I can initialize
d = CreateObject("Scripting.Dictionary")
d.Add( "a", "Athens" )
d.Add( "b", "Belgrade" )
d.Add( "c", "Cairo" )
Which errors with k = d.Keys(i) is NOT a Collection
For i= 0 to (n - 1)
k = d.Keys(i)
t = d.items(i)
message( "Item %t%","key %k%")
Next
[code]
Basically just checking on a few script snippets that worked in Win 7 using COM Objects.[/size][/font]
I hate stumbling on something that works after posting... this worked.
ForEach k in d.Keys
message(k,d.item(k))
Next
Or
a = d.keys()
for i = 0 to d.count - 1
k = a[i]
next
Or just use WIL maps.
Thanks. I'm really more interested in not being able to initialize vba.collection - it exists in my Excel 2019 Object Inspector and the references are correct, but even using it in an excel macro I get the 429 error. My AccessDatabase Engine is for 2016, I had 2010 but had issues scripting with the ACE.OLEDB provider. There is also a Microsoft.VisualBasic.Collection which may work with WB and the CLR. Basic rock and hard place - While I prefer a strict WB solution because it is generally easier and a real coding time saver - I need to hedge my bets by linking in COM or NET objects or pushing Powershell code.
Hi Tony,
What are WIL Maps?
WIL Maps are the WIL implementation of associative arrays. Navigate to Home -> Windows Interface Language Reference -> Functions -> Alphabetical -> MapCreate in the Consolidated WIL Help file for a concise explanation of WIL map usage. Go to Home -> Windows Interface Language Reference -> Functions -> By Type -> Maps (Associative Arrays) -> Map Functions in the Consolidated WIL Help file to get a brief definition of WIL maps.
If you do not have that information in your copy of the Consolidated WIL Help file, you are using an old version of WinBatch and it does matter. You can't use them unless you get a newer copy of WinBatch+Compiler.
((good gracious I love the new maps -- quick, clean, gets it done))
Maps are the next best thing to sliced bread!!!