Object doesn't support this property or method error - VBA











up vote
0
down vote

favorite












I have Excel macro that pulls data from an internal website but suddenly it stopped working and spits out "Object doesn't support this property or method." error.



Debugging marks the "Set JSON" row.



Any idea how to fix this error?



Thanks.



Option Explicit

Sub Test2()
Dim buildingId$: buildingId$ = "CAR"
Dim H As Object, S As Object, X64 As Object, JSON As Object, JSON1 As Object, JSON2 As Object, Key As Variant, Keys As Object, R%, c%, body$, sort$, test$, Subkey As Variant, Subkeys As Object, Subsubkey As Variant, Subsubkeys As Object
Set H = CreateObject("New:2087C2F4-2cef-4953-A8AB-66779B670495")

H.SetAutoLogonPolicy 0
H.SetTimeouts 0, 0, 0, 0
H.Open "GET", "https://apple-orange.banana.com/shop/rms/resourceallocation/"
H.send

body = "jsonObj=%7B%22nodeId%22%3A%22PRG2%22%2C%22searchTime%22%3A%22%22%2C%22entity%22%3A%22getLaneSFMap%22%7D"

With H
.Open "POST", "https://apple-orange.banana.com/shop/rms/getdata"
.setRequestHeader "Host", "apple-orange.banana.com"
.setRequestHeader "Referer", "https://apple-orange.banana.com/shop/rms/resourceallocation/"
.setRequestHeader "Accept-Language", "en-US,en;q=0.5"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send body
End With

Sheets("Test2").Cells.ClearContents

#If Win64 Then
Set X64 = x64Solution()
X64.execScript "Function CreateObjectx86(sProgID): Set CreateObjectx86 = CreateObject(sProgID): End Function", "VBScript"
Set S = X64.CreateObjectx86("MSScriptControl.ScriptControl")
#Else
Set S = CreateObject("ScriptControl")
#End If

S.Language = "JScript"
S.AddCode "function keys(O) { var k = new Array(); for (var x in O) { k.push(x); } return k; } "

Set JSON = CallByName(CallByName(CallByName(S.Eval("(" & H.ResponseText & ")"), "result", VbGet), "getLaneSFMapOutput", VbGet), "LaneSFMap", VbGet)
Set Keys = S.Run("keys", JSON)

For Each Key In Keys
On Error Resume Next
Set JSON1 = CallByName(JSON, Key, VbGet)
Set Subkeys = S.Run("keys", JSON1)
For Each Subkey In Subkeys
Set JSON2 = CallByName(JSON1, Subkey, VbGet)
Set Subsubkeys = S.Run("keys", JSON2)
For Each Subsubkey In Subsubkeys
With Sheets("Test2")
.Cells(2 + R, 2) = Subkey
.Cells(2 + R, 1) = CallByName(CallByName(CallByName(CallByName(JSON2, Subsubkey, VbGet), "resources", VbGet), "0", VbGet), "label", VbGet)
.Cells(2 + R, 3) = Date
End With
R = R + 1
Next Subsubkey
Next Subkey
Next Key

End Sub









share|improve this question


















  • 1




    Why not just use a JSON parser? Also, have you verified that responseText?
    – QHarr
    Nov 8 at 11:33















up vote
0
down vote

favorite












I have Excel macro that pulls data from an internal website but suddenly it stopped working and spits out "Object doesn't support this property or method." error.



Debugging marks the "Set JSON" row.



Any idea how to fix this error?



Thanks.



Option Explicit

Sub Test2()
Dim buildingId$: buildingId$ = "CAR"
Dim H As Object, S As Object, X64 As Object, JSON As Object, JSON1 As Object, JSON2 As Object, Key As Variant, Keys As Object, R%, c%, body$, sort$, test$, Subkey As Variant, Subkeys As Object, Subsubkey As Variant, Subsubkeys As Object
Set H = CreateObject("New:2087C2F4-2cef-4953-A8AB-66779B670495")

H.SetAutoLogonPolicy 0
H.SetTimeouts 0, 0, 0, 0
H.Open "GET", "https://apple-orange.banana.com/shop/rms/resourceallocation/"
H.send

body = "jsonObj=%7B%22nodeId%22%3A%22PRG2%22%2C%22searchTime%22%3A%22%22%2C%22entity%22%3A%22getLaneSFMap%22%7D"

With H
.Open "POST", "https://apple-orange.banana.com/shop/rms/getdata"
.setRequestHeader "Host", "apple-orange.banana.com"
.setRequestHeader "Referer", "https://apple-orange.banana.com/shop/rms/resourceallocation/"
.setRequestHeader "Accept-Language", "en-US,en;q=0.5"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send body
End With

Sheets("Test2").Cells.ClearContents

#If Win64 Then
Set X64 = x64Solution()
X64.execScript "Function CreateObjectx86(sProgID): Set CreateObjectx86 = CreateObject(sProgID): End Function", "VBScript"
Set S = X64.CreateObjectx86("MSScriptControl.ScriptControl")
#Else
Set S = CreateObject("ScriptControl")
#End If

S.Language = "JScript"
S.AddCode "function keys(O) { var k = new Array(); for (var x in O) { k.push(x); } return k; } "

Set JSON = CallByName(CallByName(CallByName(S.Eval("(" & H.ResponseText & ")"), "result", VbGet), "getLaneSFMapOutput", VbGet), "LaneSFMap", VbGet)
Set Keys = S.Run("keys", JSON)

For Each Key In Keys
On Error Resume Next
Set JSON1 = CallByName(JSON, Key, VbGet)
Set Subkeys = S.Run("keys", JSON1)
For Each Subkey In Subkeys
Set JSON2 = CallByName(JSON1, Subkey, VbGet)
Set Subsubkeys = S.Run("keys", JSON2)
For Each Subsubkey In Subsubkeys
With Sheets("Test2")
.Cells(2 + R, 2) = Subkey
.Cells(2 + R, 1) = CallByName(CallByName(CallByName(CallByName(JSON2, Subsubkey, VbGet), "resources", VbGet), "0", VbGet), "label", VbGet)
.Cells(2 + R, 3) = Date
End With
R = R + 1
Next Subsubkey
Next Subkey
Next Key

End Sub









share|improve this question


















  • 1




    Why not just use a JSON parser? Also, have you verified that responseText?
    – QHarr
    Nov 8 at 11:33













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have Excel macro that pulls data from an internal website but suddenly it stopped working and spits out "Object doesn't support this property or method." error.



Debugging marks the "Set JSON" row.



Any idea how to fix this error?



Thanks.



Option Explicit

Sub Test2()
Dim buildingId$: buildingId$ = "CAR"
Dim H As Object, S As Object, X64 As Object, JSON As Object, JSON1 As Object, JSON2 As Object, Key As Variant, Keys As Object, R%, c%, body$, sort$, test$, Subkey As Variant, Subkeys As Object, Subsubkey As Variant, Subsubkeys As Object
Set H = CreateObject("New:2087C2F4-2cef-4953-A8AB-66779B670495")

H.SetAutoLogonPolicy 0
H.SetTimeouts 0, 0, 0, 0
H.Open "GET", "https://apple-orange.banana.com/shop/rms/resourceallocation/"
H.send

body = "jsonObj=%7B%22nodeId%22%3A%22PRG2%22%2C%22searchTime%22%3A%22%22%2C%22entity%22%3A%22getLaneSFMap%22%7D"

With H
.Open "POST", "https://apple-orange.banana.com/shop/rms/getdata"
.setRequestHeader "Host", "apple-orange.banana.com"
.setRequestHeader "Referer", "https://apple-orange.banana.com/shop/rms/resourceallocation/"
.setRequestHeader "Accept-Language", "en-US,en;q=0.5"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send body
End With

Sheets("Test2").Cells.ClearContents

#If Win64 Then
Set X64 = x64Solution()
X64.execScript "Function CreateObjectx86(sProgID): Set CreateObjectx86 = CreateObject(sProgID): End Function", "VBScript"
Set S = X64.CreateObjectx86("MSScriptControl.ScriptControl")
#Else
Set S = CreateObject("ScriptControl")
#End If

S.Language = "JScript"
S.AddCode "function keys(O) { var k = new Array(); for (var x in O) { k.push(x); } return k; } "

Set JSON = CallByName(CallByName(CallByName(S.Eval("(" & H.ResponseText & ")"), "result", VbGet), "getLaneSFMapOutput", VbGet), "LaneSFMap", VbGet)
Set Keys = S.Run("keys", JSON)

For Each Key In Keys
On Error Resume Next
Set JSON1 = CallByName(JSON, Key, VbGet)
Set Subkeys = S.Run("keys", JSON1)
For Each Subkey In Subkeys
Set JSON2 = CallByName(JSON1, Subkey, VbGet)
Set Subsubkeys = S.Run("keys", JSON2)
For Each Subsubkey In Subsubkeys
With Sheets("Test2")
.Cells(2 + R, 2) = Subkey
.Cells(2 + R, 1) = CallByName(CallByName(CallByName(CallByName(JSON2, Subsubkey, VbGet), "resources", VbGet), "0", VbGet), "label", VbGet)
.Cells(2 + R, 3) = Date
End With
R = R + 1
Next Subsubkey
Next Subkey
Next Key

End Sub









share|improve this question













I have Excel macro that pulls data from an internal website but suddenly it stopped working and spits out "Object doesn't support this property or method." error.



Debugging marks the "Set JSON" row.



Any idea how to fix this error?



Thanks.



Option Explicit

Sub Test2()
Dim buildingId$: buildingId$ = "CAR"
Dim H As Object, S As Object, X64 As Object, JSON As Object, JSON1 As Object, JSON2 As Object, Key As Variant, Keys As Object, R%, c%, body$, sort$, test$, Subkey As Variant, Subkeys As Object, Subsubkey As Variant, Subsubkeys As Object
Set H = CreateObject("New:2087C2F4-2cef-4953-A8AB-66779B670495")

H.SetAutoLogonPolicy 0
H.SetTimeouts 0, 0, 0, 0
H.Open "GET", "https://apple-orange.banana.com/shop/rms/resourceallocation/"
H.send

body = "jsonObj=%7B%22nodeId%22%3A%22PRG2%22%2C%22searchTime%22%3A%22%22%2C%22entity%22%3A%22getLaneSFMap%22%7D"

With H
.Open "POST", "https://apple-orange.banana.com/shop/rms/getdata"
.setRequestHeader "Host", "apple-orange.banana.com"
.setRequestHeader "Referer", "https://apple-orange.banana.com/shop/rms/resourceallocation/"
.setRequestHeader "Accept-Language", "en-US,en;q=0.5"
.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.send body
End With

Sheets("Test2").Cells.ClearContents

#If Win64 Then
Set X64 = x64Solution()
X64.execScript "Function CreateObjectx86(sProgID): Set CreateObjectx86 = CreateObject(sProgID): End Function", "VBScript"
Set S = X64.CreateObjectx86("MSScriptControl.ScriptControl")
#Else
Set S = CreateObject("ScriptControl")
#End If

S.Language = "JScript"
S.AddCode "function keys(O) { var k = new Array(); for (var x in O) { k.push(x); } return k; } "

Set JSON = CallByName(CallByName(CallByName(S.Eval("(" & H.ResponseText & ")"), "result", VbGet), "getLaneSFMapOutput", VbGet), "LaneSFMap", VbGet)
Set Keys = S.Run("keys", JSON)

For Each Key In Keys
On Error Resume Next
Set JSON1 = CallByName(JSON, Key, VbGet)
Set Subkeys = S.Run("keys", JSON1)
For Each Subkey In Subkeys
Set JSON2 = CallByName(JSON1, Subkey, VbGet)
Set Subsubkeys = S.Run("keys", JSON2)
For Each Subsubkey In Subsubkeys
With Sheets("Test2")
.Cells(2 + R, 2) = Subkey
.Cells(2 + R, 1) = CallByName(CallByName(CallByName(CallByName(JSON2, Subsubkey, VbGet), "resources", VbGet), "0", VbGet), "label", VbGet)
.Cells(2 + R, 3) = Date
End With
R = R + 1
Next Subsubkey
Next Subkey
Next Key

End Sub






excel vba excel-vba






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 10:07









mandmi

387




387








  • 1




    Why not just use a JSON parser? Also, have you verified that responseText?
    – QHarr
    Nov 8 at 11:33














  • 1




    Why not just use a JSON parser? Also, have you verified that responseText?
    – QHarr
    Nov 8 at 11:33








1




1




Why not just use a JSON parser? Also, have you verified that responseText?
– QHarr
Nov 8 at 11:33




Why not just use a JSON parser? Also, have you verified that responseText?
– QHarr
Nov 8 at 11:33

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205471%2fobject-doesnt-support-this-property-or-method-error-vba%23new-answer', 'question_page');
}
);

Post as a guest





































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53205471%2fobject-doesnt-support-this-property-or-method-error-vba%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Landwehr

Reims

Schenkenzell