即使您的问题已解决,我仍在回复线程由于您使用的是依赖于 ODBC 驱动程序的 ODBC 连接,如果您更改系统或想要使用多个系统,您会遇到问题
从计数中获取数据的更好方法是使用 XML API,您无需更改任何配置,您可以使用与 ODBC 相同的配置因为您只需要分类帐名称,您可以使用下面的代码来获取分类帐名称并发布到数据a2 在标签中更改 XML 中的公司名称,<SVCURRENTCOMPANY>ABC Company</SVCURRENTCOMPANY>
甚至在标签中打开了多个公司,它从目标公司获取数据
Public Sub GetTallyLedgersList()
Dim xmlhttp As New MSXML2.XMLHTTP60, myurl As String
Dim objXML As New MSXML2.DOMDocument60
myurl = "http://localhost:9000"
xmlhttp.Open "POST", myurl, False
xmlhttp.send "<ENVELOPE><HEADER><VERSION>1</VERSION>
<TALLYREQUEST>Export</TALLYREQUEST><TYPE>Data</TYPE><ID>List Of Ledgers</ID></HEADER><BODY><DESC><STATICVARIABLES><SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT><SVCURRENTCOMPANY>ABC Company</SVCURRENTCOMPANY></STATICVARIABLES>" & _
"<TDL><TDLMESSAGE><REPORT ISMODIFY=""No"" ISFIXED=""No"" ISINITIALIZE=""No"" ISOPTION=""No"" ISINTERNAL=""No"" NAME=""List Of Ledgers""><FORMS>List Of Ledgers</FORMS></REPORT><FORM ISMODIFY=""No"" ISFIXED=""No"" ISINITIALIZE=""No"" ISOPTION=""No"" ISINTERNAL=""No"" NAME=""List Of Ledgers"">" & _
"<TOPPARTS>List Of Ledgers</TOPPARTS><XMLTAG>ListOfLedgers</XMLTAG></FORM><PART ISMODIFY=""No"" ISFIXED=""No"" ISINITIALIZE=""No"" ISOPTION=""No"" ISINTERNAL=""No"" NAME=""List Of Ledgers""><TOPLINES>List Of Ledgers</TOPLINES><REPEAT>List Of Ledgers : FormList Of Ledgers</REPEAT><SCROLLED>Vertical</SCROLLED>" & _
"</PART><LINE ISMODIFY=""No"" ISFIXED=""No"" ISINITIALIZE=""No"" ISOPTION=""No"" ISINTERNAL=""No"" NAME=""List Of Ledgers""><LEFTFIELDS>NAME</LEFTFIELDS></LINE><FIELD ISMODIFY=""No"" ISFIXED=""No"" ISINITIALIZE=""No"" ISOPTION=""No"" ISINTERNAL=""No"" NAME=""NAME""><SET>$NAME</SET><XMLTAG>NAME</XMLTAG></FIELD>" & _
"<COLLECTION ISMODIFY=""No"" ISFIXED=""No"" ISINITIALIZE=""No"" ISOPTION=""No"" ISINTERNAL=""No"" NAME=""FormList Of Ledgers""><TYPE>Ledger</TYPE></COLLECTION></TDLMESSAGE></TDL></DESC></BODY></ENVELOPE>"
Set objXML = New MSXML2.DOMDocument60
k = xmlhttp.responseText
If Not objXML.LoadXML(k) Then 'strXML is the string with XML'
Err.Raise objXML.parseError.ErrorCode, , objXML.parseError.reason
End If
Set Nameslist = objXML.SelectNodes("//LISTOFLEDGERS/NAME")
Count = 2
ActiveSheet.Cells(1, 1).Value = "Ledger Names"
For Each Name In Nameslist
s = Name.nodeTypedValue
ActiveSheet.Cells(Count, 1).Value = s
Count = Count + 1
Next
End Sub