Reputation: 79
I am working in VBA. I want to convert JS array to VBA array. I almost there. I am filling Array: "Classarray" successfully! However I have a problem with calling a function which will convert it to VBA Array. The function which I use is here:
Dim SortedArray As Variant
Dim jsObj As New ScriptControl
jsObj.Language = "JScript"
With jsObj
.AddCode _
"var classArray = new Array();" & ArrayString & _
"function setArray(ja) {" & _
"var dict = new ActiveXObject('Scripting.Dictionary');" & _
"for (var i=0;i < ja.length; i++ )dict.add(i,ja[i]);" & _
"return dict.items();}"
SortedArray = .Run("setArray", classArray)
End With
The problem is in line "SortedArray = .Run("setArray",classArray). I have got error "Error:5007 'lenght' is null or not an object" In debug mode when point on classarray it display "empty", but it isn't! See attached .jpg. Could you tell me what am I doing worng with .Run function?? Thanks.
Upvotes: 1
Views: 582
Reputation: 79
Ok I solved it. In function I replaced "ja" with "classarray".Sorry for posting a question which I answered by myself, I tried to find solution whole day. Anyway, may someone will use this code for his own purpose.
Upvotes: 1