Skip to content

Run-time error '5' Invalid procedure call or argument #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JoB4031 opened this issue Feb 16, 2024 · 2 comments
Closed

Run-time error '5' Invalid procedure call or argument #265

JoB4031 opened this issue Feb 16, 2024 · 2 comments

Comments

@JoB4031
Copy link

JoB4031 commented Feb 16, 2024

I have been struggling to understand and debug this error. I am on an M1 Mac with macOS Ventura running Excel 16.82. I have imported both this VBA-JSON module and Dictionary/KeyVaule Pair Class modules.

When I try and ParseJson on the below text I get a run-time error in the Private Function json_ParseObject 26th line down where json_ParseObject.Item(json_Key) = json_ParseValue(json_String, json_Index) under the Else conditional. It seems to be because the json_NextChar is a true/false value that isn't bracketed by quotes. I tried to add an elsif that looked for the NextChar of "f" for false or "t" for true, but not sure what code needs to go after. I tried json_ParseObject.Item(json_Key) = True but this caused a JSON parse error 10001, expecting " or '. Thank you for correcting my confusion.

Example validated JSON is attached.
JSON text.txt

@Nick-vanGemeren
Copy link

Your text parses OK on a Windows system with VBA-Dictionary and VBA-JSON (and no Scripting Runtime).

You didn't state which text line was causing the error, although you imply it was "hasNextPage": true. This pair is the first time a dictionary object is used. So maybe something is wrong with the Dictionary class module.

Simplify the troubleshooting with a small sub:

Sub TestDict()
    Dim Dict As New Dictionary
    Dict.Item("A") = 123
    Debug.Print Dict.Item("A")
End Sub

Make sure you import the source code extracted from the zip packages (no direct download).

@JoB4031
Copy link
Author

JoB4031 commented Feb 19, 2024

Thank you for the response. It does appear to be an issue with the Dictionary as the same error is raised with the small sub above on Dict.Item("A") = 123. It is a RunTime Error '5'. Invalid procedure call or argument.

I re-downloaded the Dictionary and imported the module. It now runs appropriately. I am not sure what I did incorrectly the first time, but thank you again.

@JoB4031 JoB4031 closed this as completed Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants