RubyPDF Blog .NET,My Software Batch Import XML to MS Access Database

Batch Import XML to MS Access Database

A requirement of my customer is as follow,

In access there’s the possibilities to import an xml file into a table but the problem is that the procedure is manual and is possible to import a file once a time. I ask you if you can develop a VB utility trough out I can select a list of XML files and append them to a specific table.

After researched, i knew, he means ImportXML Method,

Imports data and/or presentation information for a Microsoft Access object from an XML file or files.

expression.ImportXML(DataSource, DataTransform, OtherFlags)

expression   Required. An expression that returns an Application object.

DataSource  Required String. The name and path of the XML file to import.

DataTransform  Optional String. The name of the XSL file to apply to the incoming XML data.

OtherFlags  Optional Long. A bit mask which specifies other behaviors associated with importing from XML. The following table describes the behavior that results from specific values; values can be added to specify a combination of behaviors.

Value Description
1 Overwrite  The import file silently overwrites the target should it already exist.
2 Don’t create structure  By default, new structures are created. If Overwrite is not set, an alert asks the user for permission to overwrite.
4 Don’t import data  By default, data is imported when a data document is used to create a schema.


The following example imports an XML file representing a table called Invoices into the current database. Access overwrites the Invoices table if it already exists.

Application.ImportXML _
    DataSource:="C:\XMLData\Invoices.xml", _

It is very easy to implement, but any way, it is a very useful utility.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.