I am getting an error in the below VBA. It is throwing an error on the Set Book = Workbooks.OpenXM(FilePath. Unfortunately, this is not my Code and the guy who wrote it is uncontactable. Can anyone please advise me as to what this line is looking for? The purpose of the Code is to import an XML file into an Excel File.
Sub importITE()
Dim FilePath As String
Dim Book As Workbook
Dim oFSO As Object
Dim oFolder As Object
Dim oFile As Object
Dim i As Integer
' Load XML Data to New Workbook
FilePath = "C:\Users\Joebloggs\Documents\Sample Reconciliations\ITE\*.xml"
Set Book = Workbooks.OpenXML(FilePath)
'Copy to active Worksheet
Book.Sheets(1).UsedRange.Copy ThisWorkbook.Sheets("ITE").Range("A1")
Set oFSO = CreateObject("Scripting.FileSystemObject")
'Close New Workbook
Book.Close False
End Sub
Workbooks.OpenXMLdoesn't work with a wildcard in the filepath. You can useDirif you need to get the actual file name.OpenXML-command - a wildcard will not work