Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing all text files in a folder 1

Status
Not open for further replies.

cabletek

Technical User
Oct 11, 2002
14
US
I'm trying to automate importing all (or any) text files in a specified folder without having to enter the entire file name for the TransferText function in a Marco? The macro works fine of course if I enter in the entire path and file name, but I need it to be able to import any .txt files in the folder without editing the macro every time.
 
Convert your macro to VB code. Before the macro, use Access's Dir function to create an array of all the .txt files in the directory. Loop thorugh the array, and run the converted-macro code for each of the files in the array, substituting the name each time.... Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
I assume I would leave the "File Name" argument in the Macro blank before converting it?
 
Either way.......if you leave some name in there, you can see the exact format and location of where it goes in the macro.....might be a bit easier in the long run. Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
I get now, can help me out with the code? I'm a beginner at VB programming (had to get into it by necessity to solve some problems!).
 
sure...give me a few mintues to put together some code for you..... Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
send me an email at my address in my sig block.

I have a sample database for you that does everythign you need, except your macro code....I will forward it to you. Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
I'm needing to do he same thing. Cabletek, were you able to get this to work? If yes, could I get a copy of it?

Thanks
Bennie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top