Reputation: 105
I have a number of local JSON files which I am trying to open as a string using VBA in order to extract specific information from them into Excel.
I have seen a similar exercise work when the files are accessed by HTTP (using New.WinHTTP.WinHTTPRequest), however when I've tried to adapt this using a FILE:/// prefix it won't work.
Is there a different Excel method I can use to access the string content of the JSON file?
Cheers
Chris
Upvotes: 2
Views: 5158
Reputation: 175916
Reading from disk is not really something you would adapt code that reads from a url to do.
You can load it into memory with;
dim hf As integer: hf = freefile
dim data as string
open "c:\bla\bla.bla" for input as #hf
data = input$(LOF(hf), #hf)
close #hf
debug.? data
There are many results for JSON parsing in vba.
Upvotes: 3