Reputation: 737
I have a multiple xml files(eg 100 xml files) in a folder, my requirement is to create a macro to copy the content of the xml files and paste it in excel sheet.
For example: 1st xml file content -> Excel cell A1 2nd xml file content -> Excel cell A2 and so on..
Upvotes: 0
Views: 1318
Reputation: 7735
This will look at all xml files in a given folder and then copy the contents to your column A on Sheet1:
Sub LoopThroughFiles()
Dim MyData As String
Dim LastRow As Long
x = 1
LastRow = Sheet1.Cells(Sheet1.Rows.Count, "A").End(xlUp).Row
Dim StrFile As String
StrFile = Dir("C:\Users\User3282573\*.xml") 'change this path to your folder path
Do While Len(StrFile) > 0
Open "C:\Users\User3282573\" & StrFile For Binary As #1 'also change this path
MyData = Space$(LOF(1))
Get #1, , MyData
Sheet1.Cells(x, 1).Value = MyData
x = x + 1
Close #1
StrFile = Dir
Loop
End Sub
Upvotes: 1