Import Web XML Files into Microsoft Access Using VBA
Question details
Automate the import of XML data from the web into Microsoft Access using VBA.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- The user wants to replace repeated manual XML imports with a VBA procedure that can also handle transformations when needed.
- Observed behavior
- XML data is downloaded and imported into Access programmatically, with an optional XSL transformation before import.
Confirm that you can access the XML URL and that the XML structure is suitable for the Access tables you want to use. Enable VBA only for a trusted database and download XML from a trusted source.
Download and import the XML file with Access VBA
Use this approach to retrieve an XML file from a web URL and import it into Access without using the import wizard each time.
The example saves the response to the Windows temporary folder, then calls Application.ImportXML. It uses acStructureAndData to create the imported structure and data; importing the same structure repeatedly may create additional tables.
In Access, open the target database, press Alt+F11, and select Insert > Module.
Paste this code into the module and replace the example URL with your XML address: Public Sub ImportWebXML() Dim request As Object Dim stream As Object Dim xmlPath As String xmlPath = Environ$("TEMP") & "\access-import.xml" Set request = CreateObject("MSXML2.ServerXMLHTTP.6.0") request.Open "GET", "https://example.com/data.xml", False request.Send If request.Status <> 200 Then Err.Raise vbObjectError + 1000, , "XML download failed: HTTP " & request.Status End If Set stream = CreateObject("ADODB.Stream") stream.Type = 1 stream.Open stream.Write request.responseBody stream.SaveToFile xmlPath, 2 stream.Close Application.ImportXML DataSource:=xmlPath, ImportOptions:=acStructureAndData End Sub
Place the cursor inside ImportWebXML and press F5 in the VBA editor. Return to the Access Navigation Pane and check the imported tables.
To append to compatible existing tables instead, change acStructureAndData to acAppendData. Test the import against the existing table structure first.

Transform XML with XSL before importing it
Use an XSL transformation when the downloaded XML needs to be reshaped before Access imports it.
Review Access exports in WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface and support for Microsoft Office formats, making it easy to move exported data into a spreadsheet workflow. It does not replace Access VBA or automate Access XML imports.

Frequently Asked Questions
Can I append XML data to an existing Access table?
Yes. Use Application.ImportXML with ImportOptions:=acAppendData when the existing tables are compatible with the XML structure. Test the import before relying on it for repeated runs.
When should I use TransformXML?
Use Application.TransformXML before ImportXML when an XSL stylesheet is needed to convert the source XML into a structure that Access can import.
Can I inspect the XML before importing it?
Yes. Use MSXML2.DOMDocument60 in VBA to load and inspect the XML, then save the prepared XML to a file and pass its path to Application.ImportXML.
Can VBA run a saved Access import?
Yes. Use DoCmd.RunSavedImportExport with the name of a saved import operation. For XML-specific processing or transformations, ImportXML and TransformXML provide more direct control.
Can WPS Office run this Access import procedure?
No. The procedure requires Microsoft Access and its VBA methods. To review the resulting data in WPS Spreadsheet, export an Access table to an Excel file using External Data > Export > Excel.




