error# -2146697203 when importing xml into access with code

B

bill

when i use access imports xml tool i can manually imports schema an
data and
after i can manually append data .
i want write a code to imports 300 xml files from a directory. first i
have
imports xml structure manually
But when i try to imports (append data ) xml files from directory ,
macro
returns an error: " ImportXML method of '_Application' object "
error# -2146697203




Private Sub cmdImport_Click()
'verify xsl files exist
Dim results As Variant
If Not FileExists(CurrentProject.Path & "\erwinentities.xsl") Then
'Call MsgBox("ErwinEntities.xsl file is missing. Import
Aborted!", vbCritical, Application.Name)
'Exit Sub
End If
If Not FileExists(CurrentProject.Path & "\ErwinAttributes.xsl") Then
'Call MsgBox("ErwinAttributes.xsl file is missing. Import
Aborted!", vbCritical, Application.Name)
'Exit Sub
End If
'verify dest tables exist and delete all records
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = CurrentProject.Connection
.CommandText = "delete * from ErwinEntities"
.Execute
.CommandText = "delete * from ErwinAttributes"
.Execute
End With
Set cmd = Nothing

'import and transform xml
Application.TransformXML _
DataSource:=Me.txtErwinXML, _
TransformSource:="ErwinEntities.xsl", _
OutputTarget:="ErwinEntities.xml", _
WellFormedXMLOutput:=False
Application.ImportXML _
DataSource:="ErwinEntities.xml", _
ImportOptions:=acAppendData


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top