Browse through file names of Windows directory

A

alexhatzisavas

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
 
D

Douglas J Steele

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
 
A

alexhatzisavas

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
 
Top