Ошибка «Переменная не определена» в JsonConverter при выполнении в VBA - PullRequest
0 голосов
/ 23 мая 2019

Я хотел бы попросить вашей помощи относительно моего кода, я пытаюсь преобразовать Excel в файл Json, и у меня возникла / обнаружена ошибка, переменная не определена, Может кто-то сказать мне, что отсутствует, может быть Ссылка или отсутствует декларация

Ниже мой код:

Sub CreateJSONFile()
Dim jsonItems As New Collection
Dim jsonDictionary As New Dictionary
Dim jsonFileObject As New FileSystemObject
Dim jsonFileExport As TextStream

Dim i As Long
Dim cell As Variant
Dim colNum As Integer

Dim excelRange As Range

Set wsDst = ThisWorkbook.Sheets("Template")
Set excelRange = Cells(1, 1).CurrentRegion

colNum = 2
For i = 2 To excelRange.Rows.Count
    If wsDst.Cells(8, colNum) <> "" And wsDst.Cells(7, colNum + 1) = "" Then
        jsonDictionary("Object") = wsDst.Cells(8, colNum)
        jsonDictionary("Xpath") = wsDst.Cells(9, colNum)
        jsonDictionary("height") = wsDst.Cells(10, colNum)
        jsonDictionary("background-color") = wsDst.Cells(11, colNum)
        jsonDictionary("width") = wsDst.Cells(12, colNum)
        jsonDictionary("font-family") = wsDst.Cells(13, colNum)
        jsonDictionary("font-size") = wsDst.Cells(14, colNum)
        jsonDictionary("font-weight") = wsDst.Cells(15, colNum)
        jsonDictionary("font-style") = wsDst.Cells(16, colNum)
        jsonDictionary("font-stretch") = wsDst.Cells(17, colNum)
        jsonDictionary("line-height") = wsDst.Cells(18, colNum)
        jsonDictionary("letter-spacing") = wsDst.Cells(19, colNum)
        jsonDictionary("color") = wsDst.Cells(20, colNum)

        jsonItems.Add jsonDictionary
        Set jsonDictionary = Nothing
    End If
    colNum = colNum + 1
Next i

MsgBox JsonConverter.ConvertToJson(jsonItems, Whitespace:=3)
Set jsonFileExport = jsonFileObject.CreateTextFile(ThisWorkbook.Sheets("Template").Cells(1, 2).Value & "\" & ThisWorkbook.Sheets("Template").Cells(7, 2).Value & ".json", True)
jsonFileExport.WriteLine (JsonConverter.ConvertToJson(jsonItems, Whitespace:=3))

Set wsDst = Nothing

End Sub
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...