Open HighTechForms opened 7 years ago
Hello,
There is an incompatibility with the dictionary object of Word. Insert "scripting." before the term dictionary. Example:
Private Function json_ParseObject(json_String As String, ByRef json_Index As Long) As scripting.Dictionary
Dim json_Key As String
Dim json_NextChar As String
Set json_ParseObject = New scripting.Dictionary
@StephaneSM thanks for responding. I'll have to investigate why this only occurs in Word, I'll see if there's a good way to fix this at the library level (ideally you wouldn't need to edit anything to get it to work out-of-the-box in Word)
I can confirm this is not limited to Word, but I did manage to narrow down the problem and have a solution. You must make sure that the "Microsoft Scripting Runtime" comes before any of the Microsoft Word references. In other words, the scripting runtime reference must have higher priority in the References list than the other Microsoft references.
I would recommend that the readme be updated to inform users that might make use of any conflicting references.
I can confirm the same issues, changing to scripting.Dictionary
helped
Maintainers: Please change the module to use "New Scripting.Dictionary" anyway.
The full syntax is compatible both with Word and with Excel, whereas "new Dictionary" is compatible only with Excel.
Or at least write about it in the Readme.md, just next to the "add reference to MS Scripting", e.g. "In order to run it in MS-Word, replace any "New Dictionary" with "New scripting.Dictionary". Excel developers should run it as is".
I confirm the issue scripting.Dictionary
not really helped.
the error occure on this line
I m using the lib with Word in Office 360.
Error on compile: Method or data object not found.
Hi, i found a solution thats works for me in word. Just edit the function 'json_Object'. Create the dictionary at runtime and return an object instead of Dictionary. Like This:
Hello,
There is an incompatibility with the dictionary object of Word. Insert "scripting." before the term dictionary. Example:
Private Function json_ParseObject(json_String As String, ByRef json_Index As Long) As scripting.Dictionary Dim json_Key As String Dim json_NextChar As String Set json_ParseObject = New scripting.Dictionary
Hello,
In order to avoid error "Method or data object not found" at json_ParseObject.Item(json_Key)
, dont forget to add "Scripting." in both:
Private Function json_ParseObject(json_String As String, ByRef json_Index As Long) As Scripting.Dictionary
Set json_ParseObject = New Scripting.Dictionary
Has anyone made a pull request on this ? I strongly suggest MoSad85's solution, in other words switch the library to late binding, since early binding is a known source of troubles.
Well, a pull request is done, and up for review.
I think that my solution is the best for above error. https://github.com/VBA-tools/VBA-JSON I didn't face any error when I used above jsonconverter in excel vba for userform. But I faced same error in excel vba project for form control. MoSad85's solution is not working to me.
Solution: 1.Remove MS script runtime library from reference in excel vba 2.Import above cls to vba project.
That's all
It's crashing on the line where it sets json_ParseObject.