Feb 6, 2002 #1 luceze Programmer Apr 26, 2001 842 US Is there a way to populate a table with the file names from a directory. I tried messing with the Dir function but could not get it to work. Thanks, Eric
Is there a way to populate a table with the file names from a directory. I tried messing with the Dir function but could not get it to work. Thanks, Eric
Feb 6, 2002 1 #2 SuzieQQ Programmer Feb 6, 2002 5 CA use the DOS redirection symbol ">>" to direct the listing to a text file, e.g. DIR *.* >> FILENAMES.TXT Then you can import this file into a table. Upvote 0 Downvote
use the DOS redirection symbol ">>" to direct the listing to a text file, e.g. DIR *.* >> FILENAMES.TXT Then you can import this file into a table.
Feb 6, 2002 Thread starter #3 luceze Programmer Apr 26, 2001 842 US Perfect! Thanks! Upvote 0 Downvote
Feb 6, 2002 1 #4 jfischer Programmer May 24, 2001 343 US What doesn't work for you with the Dir() function? Try adapting the following code. Code: Dim sFile As String sFile = Dir("C:\*.*", vbNormal) Do While sFile & "" <> "" Debug.Print sFile sFile = Dir() Loop Upvote 0 Downvote
What doesn't work for you with the Dir() function? Try adapting the following code. Code: Dim sFile As String sFile = Dir("C:\*.*", vbNormal) Do While sFile & "" <> "" Debug.Print sFile sFile = Dir() Loop
Feb 6, 2002 Thread starter #5 luceze Programmer Apr 26, 2001 842 US jfischer, I tried it but I'm not sure what's supposed to happen. How should I call the function and how do I display the output. Here's what I used: Public Function FileName() Dim sfile As String sfile = Dir("C:\winnt\profiles\ExcelFiles\*.xls", vbNormal) Do While sfile & "" <> "" Debug.Print sfile sfile = Dir() Loop End Function Upvote 0 Downvote
jfischer, I tried it but I'm not sure what's supposed to happen. How should I call the function and how do I display the output. Here's what I used: Public Function FileName() Dim sfile As String sfile = Dir("C:\winnt\profiles\ExcelFiles\*.xls", vbNormal) Do While sfile & "" <> "" Debug.Print sfile sfile = Dir() Loop End Function
Feb 6, 2002 #6 SusieQQ MIS Apr 14, 2002 1 AU That code does not populate a table; it just prints the file. Upvote 0 Downvote
Feb 6, 2002 #7 jfischer Programmer May 24, 2001 343 US This is just a code sample. You need to adapt it to your situation. To test the sample code as you entered it: 1) Open a Debug (Immediate) window [press Ctrl-G]. 2) Type the following: Code: ? FileName() If the function runs properly you should see a list of Excel spreadsheets appear in the Debug window. Your next step is to change the Debug.Print statement into the appropriate statements to add records to your file name table. Upvote 0 Downvote
This is just a code sample. You need to adapt it to your situation. To test the sample code as you entered it: 1) Open a Debug (Immediate) window [press Ctrl-G]. 2) Type the following: Code: ? FileName() If the function runs properly you should see a list of Excel spreadsheets appear in the Debug window. Your next step is to change the Debug.Print statement into the appropriate statements to add records to your file name table.
Feb 6, 2002 Thread starter #8 luceze Programmer Apr 26, 2001 842 US Got it. Thanks guys. Upvote 0 Downvote