简体   繁体   English

使用VBA宏将xml导出到excel时,标题/标签未显示

[英]headers/ tags are not displaying when an xml is exported to excel using VBA Macro

I am using the below code to export the xml to excel. 我正在使用以下代码将xml导出到excel。

Sub ImportXMLtoList()  

    Dim strTargetFile As String  
    Application.DisplayAlerts = False
    strTargetFile = "C:\XML_Demo\demo.xml"  
    Workbooks.OpenXML Filename:=strTargetFile, LoadOption:=xlXmlLoadImportToList
    Application.DisplayAlerts = True  

End Sub

While this code is executed, xml values are being displayed in spreadsheet, but not the corresponding tags. 执行此代码时,xml值显示在电子表格中,而不显示相应的标记。 "demo.xml" is a dummy xml I have put here, as I work on client data, I cannot share the actual xml which has this problem. “ demo.xml”是我在此处输入的虚拟xml,因为我处理客户端数据时无法共享存在此问题的实际xml。 The same code works for other xmls. 相同的代码适用于其他xml。 Please let me know what would be the issue. 请让我知道会出现什么问题。

试用Workbooks.OpenXML Filename:=strTargetFile, LoadOption:=xlXmlLoadOpenXml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM