我正在使用VBA中编写的宏将我的工作簿中的所有工作表同时导出到XML,但是我为列上的标题创建了Mappings,但它们并未随工作表一起导出。 仅当我转到Developer标签并导出为XML时,它才起作用。
是否可以在分配映射的同时将所有工作表导出为XML?
Sub Splitziez()
Dim strPath As String
strPath = "C:\Test"
For Each sheetz0r In ThisWorkbook.Sheets
sheetz0r.Copy
Application.ActiveWorkbook.SaveAs FileFormat:=xlXMLSpreadsheet,
Filename:=strPath & "\" & sheetz0r.Name
Application.ActiveWorkbook.Close False
Next
End Sub
答案 0 :(得分:0)
尝试:
Option Explicit
Sub test()
Dim ws As Worksheet
Dim strpath As String
Dim xFile As String
strpath = "C:\Test"
For Each ws In ThisWorkbook.Worksheets
ws.Copy
xFile = strpath & "\" & ws.Name & ".XML"
Application.ActiveWorkbook.SaveAs xFile
Application.ActiveWorkbook.Close False
Next
End Sub