473,396 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Import XML Files into Access 2003 via VB

Can someone help me with this?

I am running Access 2003 and attempting to import and append multiple XML files into Access. I currently do this process using the Import tool built into Access’s File menu. The only problem with this is that I have to do one file at a time and I have hundreds of files to import.

I would like to be able to use code to loop through all the files contained within a specified folder and import and append the files into my database.
I am not very familiar with writing code but this does not seem like it should be that difficult to do. Here is what I have currently. If someone could help me with this it would be much appreciated.

Private Sub cmdImport_Click()
Dim strFile As Variant
Dim strPath As String
strPath = "Z:\Data\AutoImport"
strFile = Dir(strPath & "savfile*.XML")
Do While Len(strFile) > 0
Application.ImportXML strPath & strFile, 2
Loop
MsgBox "Import Completed"
End Sub
Jun 25 '07 #1
1 9576
MMcCarthy
14,534 Expert Mod 8TB
OK, try this. It will build an array of the list of files and then cycle them for import

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdImport_Click()
  2. Dim strFile As String 'Filename
  3. Dim strFileList() As String 'File Array
  4. Dim intFile As Integer 'File Number
  5. Dim strPath As String ' Path to file folder
  6.  
  7.     strPath = "Z:\Data\AutoImport\"
  8.     strFile = Dir(strPath & "savfile*.XML")
  9.  
  10.     While strFile <> ""
  11.          'add files to the list
  12.         intFile = intFile + 1
  13.         ReDim Preserve strFileList(1 To intFile)
  14.         strFileList(intFile) = strFile
  15.         strFile = Dir()
  16.     Wend
  17.  
  18.      'see if any files were found
  19.     If intFile = 0 Then
  20.         MsgBox "No files found"
  21.         Exit Sub
  22.     End If
  23.  
  24.     'cycle through the list of files
  25.     For intFile = 1 To UBound(strFileList)
  26.         Application.ImportXML strPath & strFileList(intFile), 2
  27.     Next intFile
  28.  
  29.     MsgBox "Import Completed"
  30.  
  31. End Sub
  32.  
Jun 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dan | last post by:
Could someone please help me with auto importing a series of data files into an Access table. I tried to follow code given below in a previous messagebut i'm getting error messages. Here's my...
1
by: musicloverlch | last post by:
What's up with the text import wizard in Access 2003? We have a large text file that needs to be imported. Tried it on Access 2003 and it just sits there with an hourglass. Tried it on Access 97...
2
by: veaux | last post by:
Peeked around here but didn't really see an explanation as to the varied "Invalid Argument" errors that appear in Access sometimes. I'm using Access 2003 and trying to import an Access table of...
1
by: tezza98 | last post by:
I need some help. Im using a dtsrun command to import 9 tables into an Access database, most of the tables have about 1000 rows, but one has 20000+ rows and grows everyday. Im Using Access 2003...
3
by: MarcGA | last post by:
(Excel 2003, Access 2003, XP, novice user here) I can't get Access to accept multiple Excel files to the same table. I can import the spreadsheets to a new table, but I need to import 23...
1
by: Pauline | last post by:
Dear all, I have an enormous database (Access 2003) containing sales information, and an Excel tool to enable end users to do planning and forecasting. Untill now I would create several queries,...
8
by: shenkel55 | last post by:
I'm using Access and Excel 2003. Using either the import wizard or code, I have the same problem. This problem only happens with Excel files automatically generated by Corp IT. If I try to do an...
4
by: Alvin SIU | last post by:
Hi all, I have 6 tables inside a MS Access 2003 mdb file. I want to convert them as DB2 version -8 tables in AIX 5.2. I have exported them as 6 XML files. The XML files look fine. Each...
9
by: a | last post by:
Dear friends I want import data from CSV file to mdb file How can I do that in vb.net?
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.