I am using Microsoft Access 2010 to write VBA code to save an Access table as an XML file. I have tried running on computers with Windows 10 and Windows 8.1 In both cases I get the error “2302 Can’t save output data to the file you selected.” Here is the code I’m using
Sub cmdxml_Click()
Dim objOtherTbls As AdditionalData
On Error GoTo ErrHandler
Set objOtherTbls = Application.CreateAdditionalData
' table to export
objOtherTbls.Add "tblAssociates"
'export here
Application.ExportXML ObjectType:=acExportTable, DataSource:="tblAssociates", _
DataTarget:=" C: \Documents\rayBuild\EmployeeData.xml", _
AdditionalData:=objOtherTbls
MsgBox "Export operation completed successfully."
Exit Sub
ErrHandler:
MsgBox Err.Number & " " & Err.Description
End Sub
I have used the ribbon External Data, Export, XML Data and successfully save an XML and SD files.
Any help getting the VBA code to work is appreciated
Thanks
Sub cmdxml_Click()
Dim objOtherTbls As AdditionalData
On Error GoTo ErrHandler
Set objOtherTbls = Application.CreateAdditionalData
' table to export
objOtherTbls.Add "tblAssociates"
'export here
Application.ExportXML ObjectType:=acExportTable, DataSource:="tblAssociates", _
DataTarget:=" C: \Documents\rayBuild\EmployeeData.xml", _
AdditionalData:=objOtherTbls
MsgBox "Export operation completed successfully."
Exit Sub
ErrHandler:
MsgBox Err.Number & " " & Err.Description
End Sub
I have used the ribbon External Data, Export, XML Data and successfully save an XML and SD files.
Any help getting the VBA code to work is appreciated
Thanks