Edmond
03-11-2019, 11:39 AM
Hi everyone,
I have found this code, perfectly working, to do as the title indicates it:
Sub NameChanging()
Dim fls, f
Set fls = GetFiles("C:\Users\Test\", "*.pdf*")
For Each f In fls
Debug.Print f
Next f
End Sub
Function GetFiles(path As String, Optional pattern As String = "") As Collection
Dim rv As New Collection, f
If Right(path, 1) <> "\" Then path = path & "\"
f = Dir(path & pattern)
Do While Len(f) > 0
rv.Add path & f
f = Dir() 'no parameter
Loop
Set GetFiles = rv
End Function
None the less, I have troubles finding out how it does work without "dimensioning" the variables f and fls.
Could someone explain me briefly what's the purpose of not mentioning the dimension? And a some explanation on the typo? "Dim Name As Var, f?"
Thank you!
I have found this code, perfectly working, to do as the title indicates it:
Sub NameChanging()
Dim fls, f
Set fls = GetFiles("C:\Users\Test\", "*.pdf*")
For Each f In fls
Debug.Print f
Next f
End Sub
Function GetFiles(path As String, Optional pattern As String = "") As Collection
Dim rv As New Collection, f
If Right(path, 1) <> "\" Then path = path & "\"
f = Dir(path & pattern)
Do While Len(f) > 0
rv.Add path & f
f = Dir() 'no parameter
Loop
Set GetFiles = rv
End Function
None the less, I have troubles finding out how it does work without "dimensioning" the variables f and fls.
Could someone explain me briefly what's the purpose of not mentioning the dimension? And a some explanation on the typo? "Dim Name As Var, f?"
Thank you!