B
Bob
The code below works.
It is just a simple loop that lists files in my "C:\Less\In\"
directory.
Notice that the "Calculate" keyword is memo only.
Now if I activate calculate by removing the "'" I get a "Run-time
error 5 " message on the first run of the Sub. On subsequent runs it
is ok ?!
(The "str_FileName = Dir " line is highlighted on Debug)
If I adjust its position on the line (not within the code itself) I
get the message on the first Sub run again!
How can this be?
Sub L()
Dim str_FileName As String 'Name of file in AllJnls folder.
Dim str_MyPath As String 'Path to the AllJnls folder.
' Loop to get all LESS IN Files.
str_MyPath = "C:\Less\In\" ' Set the path.
str_FileName = Dir(str_MyPath) ' Retrieve the first
entry.
Do While str_FileName <> "" 'Loop for each file.
'Calculate
Debug.Print str_FileName
str_FileName = Dir ' Get next file.
Loop
End Sub
It is just a simple loop that lists files in my "C:\Less\In\"
directory.
Notice that the "Calculate" keyword is memo only.
Now if I activate calculate by removing the "'" I get a "Run-time
error 5 " message on the first run of the Sub. On subsequent runs it
is ok ?!
(The "str_FileName = Dir " line is highlighted on Debug)
If I adjust its position on the line (not within the code itself) I
get the message on the first Sub run again!
How can this be?
Sub L()
Dim str_FileName As String 'Name of file in AllJnls folder.
Dim str_MyPath As String 'Path to the AllJnls folder.
' Loop to get all LESS IN Files.
str_MyPath = "C:\Less\In\" ' Set the path.
str_FileName = Dir(str_MyPath) ' Retrieve the first
entry.
Do While str_FileName <> "" 'Loop for each file.
'Calculate
Debug.Print str_FileName
str_FileName = Dir ' Get next file.
Loop
End Sub