Import a XML file to MS Access database

Share this post
FaceBook  Twitter  Mixx.mn     

  
To Import XML data into a MS Access database, use following code:
Step:
1) Create a MS Access application object

2) Open MS Access database

3) Import XML file into Access

4) Close and Exit database

5) Discard all variables    


Code:   
'Import XML to MS Access
'==============================================
Function Import_XML_To_AccessDB(XmlFilePath,TempAccessFilePath)
'1) Create a MS Access application object'
 Set appAccess = CreateObject("Access.Application")
 
 '2) Open MS Access database
 appAccess.OpenCurrentDatabase TempAccessFilePath
 
 '3) Import XML file into Access
 appAccess.ImportXML XmlFilePath
 
 '4) Close and Exit database
 appAccess.CloseCurrentDatabase
 appAccess.Quit acExit
 
 '5) Discard all variables    

 Set appAccess = Nothing
End Function