Solved

Access VBA loop through filenames

Posted on 2014-07-31
2
1,011 Views
Last Modified: 2014-07-31
From here: - http://www.dbforums.com/microsoft-access/1647035-loading-all-file-names-static-directory-ms-access-table.html
I modified to this: -
Dim strFileName As String
FileName = Dir("c:/EPOD/*.XML")
Do While FileName <> ""
    Debug.Print strFileName
    strFileName = Dir()
Loop
This prints out all the xml files in a folder but then errors "Run time error 5 Invalid Procedure Call or Argument"

Basically, I'm trying to process all the xml files in a given folder, can anyone help?
0
Comment
Question by:HKFuey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40231358
You're referencing "FileName", but your variable is "strFileName", so try this:

Dim strFileName As String
strFileName = Dir("c:/EPOD/*.XML")
Do While strFileName <> ""
    Debug.Print strFileName
    strFileName = Dir()
Loop

Open in new window

0
 

Author Closing Comment

by:HKFuey
ID: 40231422
Thanks very much, glad it was easy!
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question