I’m using the following code to open multiple xml files, however they are opening as a read only workbook, however I require it to open as an XML table, any suggestions?
Code:
Sub AllFolderFiles()
Dim wb As Workbook
Dim TheFile As String
Dim MyPath As String
MyPath = "C:\Documents and Settings\"
ChDir MyPath
TheFile = Dir("*.xml")
Do While TheFile <> ""
'Call Logs 'This calls for Macro2 to run
Set wb = Workbooks.Open(MyPath & "\" & TheFile)
MsgBox wb.FullName
'wb.Close
TheFile = Dir
Loop
End Sub
You need to use
Workbooks.OpenXMLinsteadSet wb = Workbooks.OpenXML(Filename:=MyPath & "\" & TheFile, LoadOption:=xlXmlLoadImportToList)I’m not exactly which LoadOption you want to use, but you can choose from:
xlXmlLoadImportToListAutomatically creates an XML List and importsdata into the list.
xlXmlLoadMapXmlLoads the XML file into the XML Source task pane.xlXmlLoadOpenXmlOpen XML files in the same way that Excel 2002opens XML files (for backwards compatibility only).
xlXmlLoadPromptUserPrompts the user and lets them choose the Importmethod.