You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a simplified snippet from a project with Scripting.Dictionary, which works fine:
Sub testDict()
Dim dict As Variant
addValue dict
End Sub
Sub addValue(dict)
Dim key As String
Set dict = CreateObject("Scripting.Dictionary")
createKey key
dict(key) = "value"
End Sub
Sub createKey(key)
key = "a"
End Sub
There is the same snippet with VBA-Dictionary, and it throws an exception in Property Let Item(): "Invalid procedure call or argument" with #Const UseScriptingDictionaryIfAvailable = True or "Variable uses an Automation type not supported in Visual Basic" with #Const UseScriptingDictionaryIfAvailable = False
Sub testDict()
Dim dict As Variant
addValue dict
End Sub
Sub addValue(dict)
Dim key As String
Set dict = New Dictionary
createKey key
dict(key) = "value"
End Sub
Sub createKey(key)
key = "a"
End Sub
Note for commenters: I do not need to change anything in the project, more of that, the issue can be fixed by Dim key As Variant. The snippet is simplified as much as possible, also subs are used instead of functions because they returns data via several variables byref in the project. It works with no issues with Scripting.Dictionary, now I tried VBA-Dictionary and found some difference, that is why I reported here.
The text was updated successfully, but these errors were encountered:
There is a simplified snippet from a project with Scripting.Dictionary, which works fine:
There is the same snippet with VBA-Dictionary, and it throws an exception in
Property Let Item()
: "Invalid procedure call or argument" with#Const UseScriptingDictionaryIfAvailable = True
or "Variable uses an Automation type not supported in Visual Basic" with#Const UseScriptingDictionaryIfAvailable = False
Note for commenters: I do not need to change anything in the project, more of that, the issue can be fixed by
Dim key As Variant
. The snippet is simplified as much as possible, also subs are used instead of functions because they returns data via several variables byref in the project. It works with no issues with Scripting.Dictionary, now I tried VBA-Dictionary and found some difference, that is why I reported here.The text was updated successfully, but these errors were encountered: