Browse through file names of Windows directory

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all.

I would like to browse through the contents of a Windows directory and
manipulate the file names programmatically.

The objective is to enter the file names contained in a specific Windows
directory into a VBA array to manipulate further.

My Windows folder is:
\\livscp02\f\backup

It contains two-three hundred .zip files.

I would like to enter the file names contained in this Windows folder into a
VBA array.

The array stuff i can do, but i don't know how one gets file information
from a Windows directory.

How would i go about to address this?
Your help is very much appreciated.

Alex
 
You can use the Dir function to get the files.

Dim strFolder As String
Dim strFile As String

strFolder = "\\livscp02\f\backup\"
strFile = Dir$(strFolder)
Do While Len(strFile) > 0
' at this point, strFolder & strFile represents the full path
' to a file in that folder


' Get the next file name.
' (strFile will be a zero-length string if there are
' no more files in the folder)
strFile = Dir$()
Loop
 
Thanks Doug, appreciate it.


Douglas J Steele said:
You can use the Dir function to get the files.

Dim strFolder As String
Dim strFile As String

strFolder = "\\livscp02\f\backup\"
strFile = Dir$(strFolder)
Do While Len(strFile) > 0
' at this point, strFolder & strFile represents the full path
' to a file in that folder


' Get the next file name.
' (strFile will be a zero-length string if there are
' no more files in the folder)
strFile = Dir$()
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top