2

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

user2306403
  • 105
  • 1
  • 2
  • 4

1 Answers1

2

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.

Community
  • 1
  • 1
Alex K.
  • 171,639
  • 30
  • 264
  • 288