Maria76
01-28-2005, 02:26 AM
Hello,
How do I list the names of the files in a folder?
What is the difference between VBA and Visual Basic? It is the same syntax?
italkid
01-28-2005, 03:57 AM
Check out the Dir() function
VBA is build in by default in Office applications and can be used to automate them.
You can not build/write stand-alone programs with VBA.
VB is a program which makes it able to build stand-alone programs (exe's)
In general the syntax of the VBA and VB languages are the same.
The Dir() function works that way :
path = "your path"
'extract the first file
files = Dir(path, vbDirectory)
'loop for all files
Do While files <> ""
'ignore . and ..
If files <> "." And files <> ".." Then
'to see if it is a file
If Not ((GetAttr(path & files) And vbDirectory) = vbDirectory) Then
'do what you want with your file
End If
End If
' goto next file
files = Dir
Loop
End of the story