Re: multiple xml imports from local path



Hi Martijn,

Another MVP, Joe Fallon, posted this code a while ago to show how to use
Dir() to loop through all the files in a folder. You'll need to replace
DoCmd.TransferText with Application.ImportXML and make a few other
changes.

How to Import all Files in a Folder:

Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete them.
'assumes they are all the correct format for an ASCII delimited import.
Dim strfile As String

ChDir ("c:\MyFiles")
strfile = Dir("FileName*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "ImportSpecName", "AccessTableName",
"c:\MyFiles\" & strfile, True
'delete the file (consider moving it to an Archive folder instead.)
Kill "c:\MyFiles\" & strfile
strfile = Dir
Loop

End Sub

On Mon, 5 Sep 2005 04:51:09 -0700, "Martijn"
<Martijn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>I'm struggling with the import of xml files in access.
>
>I receive the files in outlook and save them as client(1).xml, client(2).xml
>etc in a local folder.
>When I'm using the xml import function in code I only can import a file I
>named in the code.
>
>example:
>Application.ImportXML DataSource:="D:\Clienten XML\client.xml",
>ImportOptions:=acAppendData
>(I can put in the same rule with client(2).xml etc, but there are a lot of
>files this way).
>
>This works fine but how can I tell the import engine that I want to import
>all the *.xml files from "this location" etc.
>
>I think I have to use a loop but I don't know how to define the code.
>
>Can somebody help me?
>
>Thanks

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.

.



Relevant Pages

  • Re: Checking a folder again after it has been emptied
    ... that while loop. ... allowing additional files in that folder to be moved and now with your ... #sleep timer and number of files ... closedir PRV_SRC_1; ...
    (perl.beginners)
  • Re: Outlook 2003 vba macro
    ... Don't move or delete items in a For Each loop! ... 'Move the email Item to the backup folder ... Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers ... > Dim objApp As Application ...
    (microsoft.public.outlook.program_vba)
  • Re: Help with a long running process?
    ... Before the loop enters its initial cicle, it will first have to grab ... all the files from all sub folders off the base path you specified. ... String)) or return it as an array. ... consider loading the files folder by folder: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: problems deleting email messages in c#
    ... Deleting items from a collection requires either a count down for loop or another looping construct that tests for the collection being empty. ... Hard-deleting an item (bypassing Deleted Items) is only possible using CDO 1.21 or Extended MAPI or a COM wrapper for MAPI such as Redemption. ... An alternative is to handle ItemAdd on the Items collection of the Deleted Items folder. ... I am putting together a personal project to help me remove spam out of my ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: multiple xml imports from local path
    ... > Dirto loop through all the files in a folder. ... > Private Sub btnImportAllFiles_Click ... > Dim strfile As String ...
    (microsoft.public.access.externaldata)

Loading