XML import macro running slowly

spo_rt

New Member
Joined
Nov 4, 2014
Messages
1
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.
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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top