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..
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.