xmlvbams-accessms-access-2007xml-import

XML VBA Access 2010 import


I want to integrate in my code VBA an instruction to import XML files. In the else branch of my condition, I want to add a command to import the XML files. Could you suggest me something (a VBA instruction which do the import) ?

   Private Sub Commande0_Click()
      Dim rep As String
      rep = Dir("C:\Users\Toufik\Desktop\XML\*.*", vbDirectory)
      Do While (rep <> "")
         If (GetAttr("C:\Users\Toufik\Desktop\XML\" & rep) And vbDirectory) = vbDirectory Then
            MsgBox "Directory " & rep
         Else
            MsgBox "File " & rep
         End If 
         rep = Dir
      Loop
   End Sub

Solution

  • If you want to import XML data into Access using VBA you should check out the Application.ImportXML method, described here:

    http://msdn.microsoft.com/en-us/library/ff823157%28v=office.14%29.aspx