473,803 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Import XML Files into Access 2003 via VB

1 New Member
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\AutoIm port"
strFile = Dir(strPath & "savfile*.X ML")
Do While Len(strFile) > 0
Application.Imp ortXML strPath & strFile, 2
Loop
MsgBox "Import Completed"
End Sub
Jun 25 '07 #1
1 9628
MMcCarthy
14,534 Recognized Expert Moderator MVP
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
6706
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 database stats: Path: C:\Database (contains the database and all the text files to be imported) Text files to import: (SampleData4.txt and SampleData3.txt as testing examples)
1
5673
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 and it opened right up! Any ideas? Thanks in advance, Laura
2
6588
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 ~200,000 records into my DB. I've tried importing, linking, exporting the original table to txt and importing or linking to that. Then I tried exporting the table to it's own DB (which worked) but still cant then import or link to the DB I'm using....
1
2797
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 and SQL Server 2000. on a WinXP Machine When the database is opened a stored procedure drops all the tables and then imports the csv files using dtsrun. The database is only used for reporting and the data is entered into the csv files using 3rd...
3
3618
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 spreadsheets to the same table. I'm not getting a formatting error, just a "file did not import" message. Also, when I do import one-to-one, Access inserts thousands of blank lines before the first line of imported data. How do I keep Access from doing...
1
2325
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, export the data to Excel (Excel 2003) and store the Data in the tool for the users to work with. I always have to export all information for a group of users as I never know on what part of the data they want to work. This makes the Excel files very...
8
9665
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 import and the Excel file isn't open I get the following error: "The wizard is unable to access information in the file "...path info... "Please check that the file exists and is in the correct format." If the files are opened directly in Excel, it...
4
10330
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 record is embeded by a tag which is the table name.
9
5792
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
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10289
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4274
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2968
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.