Import XML problem.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I want to import XML file into Access database. I'm using the code

Dim sXMLPath As String
Dim appAccess As Object
Set appAccess = CreateObject("Access.Application")
sXMLPath = "test4-ticket.xml"
appAccess.ImportXML DataSource:=sXMLPath, _
ImportOptions:=acStructureAndData

I got the error of "Automation error The server threw an exception." Any
help? Is this the simplest way to import XML into Access?

Thanks.

Yolande
 
You probably need to open or create a database first.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Hi,

I fixed this problem by using the Application.ImportXML

Application.ImportXML DataSource:=sXMLPath,
ImportOptions:=acStructureAndData
 
As far as I can see, that is the same code that you were using before,
except that earlier you assigned a reference to the Application object to a
variable, and called the ImportXML method via the variable. I doubt that
explains the difference. I wonder, do you have more than once version of
Access on your PC? Could it be that the call to GetObject you were using
earlier might have been returning a reference to an earlier version of
Access that did not support the ImportXML method?

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top