0

Anybody create the Excel VBA code for the following json file ?

 "Version": "1.1", "TranDtls": { "TaxSch": "GST", "SupTyp": "B2B", "IgstOnIntra": "N", "RegRev": "N", "EcmGstin": null }, "DocDtls": { "Typ": "INV", "No": "1", "Dt": "21/10/2022" 

Excel VBA code for the JSON file CREATION

1
  • 2
    Stackoverflow is not a free coding service.
    – Aldert
    CommentedOct 28, 2022 at 7:21

1 Answer 1

1

We need some more information to help you find the correct answer. Do you want to read/import this json string or do you want to have Excel create such a string for export?

You can use the VBA-JSON module from github. A simple way to create the string is to copy paste it into a string variable and use the Replace function;

sTemp = "... "TaxSch": "[TaxSch]",.... sJson = Replace(sTemp,"[TaxSch]", Yourvalue) 

Or you could use concatenation but that will be more difficult with all the quotes.

1
  • I used this code - Set objectProperties = CreateObject("Scripting.Dictionary") For Each c In ActiveSheet.ListObjects(1).HeaderRowRange.Cells objectProperties.Add c.Column, c.Value Next Dim collectionToJson As New Collection For Each r In ActiveSheet.ListObjects(1).ListRows Set jsonObject = CreateObject("Scripting.Dictionary") For Each c In r.Range.Cells jsonObject.Add objectProperties(c.Column), c.Value Next collectionToJson.Add jsonObject Next fileSaveName = Application.GetSaveAsFilename(fileFilter:="JSON Files(*.json),*json")
    – Ziyad VK
    CommentedOct 31, 2022 at 4:40

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.