+ Reply to Thread
Results 1 to 2 of 2

Import Multiple XML Files

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387

    Import Multiple XML Files

    I'm trying to write a macro that would import multiple XML files from a single folder into Excel. The current path I would use would be to go to Data->From Other Sources->From XML Import and then select each individual file. I'm looking for a way to do this entire folder at once. Any help on starting this macro out would be helpful.

  2. #2
    Forum Contributor
    Join Date
    06-03-2008
    Posts
    387
    It turned out to be pretty simpe to write. Here's how I did it:

    Sub xmlImport()
        fld = "\\filepath\folder"
        i = 1
        found = False
        fil = Dir(fld & "*.xml")
        Do While (fil <> "")
            found = False
            Location = fld & fil
            ActiveWorkbook.xmlImport URL:=Location, ImportMap:=Nothing, Overwrite:=True, Destination:=Range("$A" & i)
            Do
                If Cells(i, 1) = "" Then
                    found = True
                Else
                    i = i + 1
                End If
            Loop Until found
            fil = Dir
        Loop
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1