Data Import & Export

Import Web XML Files into Microsoft Access Using VBA

Steve KSteve K Nov 27, 2026 868 views

Question details

Automate the import of XML data from the web into Microsoft Access using VBA.

Import Web XML Files 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.
Before you start

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.

Solution 1Recommended

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.

1
Open a VBA module

In Access, open the target database, press Alt+F11, and select Insert > Module.

2
Add the import procedure

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

3
Run the procedure

Place the cursor inside ImportWebXML and press F5 in the VBA editor. Return to the Access Navigation Pane and check the imported tables.

4
Adjust repeat imports if needed

To append to compatible existing tables instead, change acStructureAndData to acAppendData. Test the import against the existing table structure first.

Download and import the XML file with Access VBA
Check the source: The example expects an accessible URL that returns XML with HTTP status 200. Authentication, redirects, or an incompatible XML structure may require additional handling.
Free Microsoft Office alternative

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.

Review and work with data exported from Access to ExcelOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interface for a smoother transitionWork with a free, lightweight Office suite
microsoft office alternative - wps office

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.