Hi all,
I am a novice at vba and attempting to import xml files from various users (each with their own sub folder in a shared drive) to a workbook template used for generating reports. To do so, I am using Excel2013 and a vba macro sub.
The project name, user names, file paths etc are stored on a sheet in the Excel Workbook. These are referenced by the sub for the locations of the xml files. The xml files for the project are imported to an xml mapped sheet in the workbook from where the data is used to generate the various reports required.
The following sub works, in that it imports the files, but in my test cases (from a previous live project of 160 xml files) it takes over 5 minutes to complete the import, which seems too long. I am looking for a method that will speed up the process. Any help or suggestions appreciated.
I am a novice at vba and attempting to import xml files from various users (each with their own sub folder in a shared drive) to a workbook template used for generating reports. To do so, I am using Excel2013 and a vba macro sub.
The project name, user names, file paths etc are stored on a sheet in the Excel Workbook. These are referenced by the sub for the locations of the xml files. The xml files for the project are imported to an xml mapped sheet in the workbook from where the data is used to generate the various reports required.
The following sub works, in that it imports the files, but in my test cases (from a previous live project of 160 xml files) it takes over 5 minutes to complete the import, which seems too long. I am looking for a method that will speed up the process. Any help or suggestions appreciated.
Code:
Sub ImportXmlFromFile()
Application.ScreenUpdating = False
Dim rng As Range
Dim cell As Range
Dim folder As Variant
Dim filename As String
'Set range of file path text contained in the Project Data tab
Set rng = Worksheets("Sheet2").Range("A27:A34")
'Specifies the filepath for each project user and the filename for each xml file in folder
For Each cell In rng
folder = cell.Text
filename = Dir(folder & "*.XML")
'For each xml file in folder, import to sheet with xml schema mapped. Append each file
Do While filename <> ""
ThisWorkbook.XmlMaps("dataroot_Map").Import URL:=folder & filename, Overwrite:=False
Loop
Next cell
Application.ScreenUpdating = True
End Sub