Hi Douglas,
Thanks for your reply - my code is scanning through a bunch of servers (it
gets the list of servers from another database via sql).
There are some servers that our team are not responsible for which do not
have the backup software installed, so by searching for that directory / file
(and having a true result returned) is the way the servers logs get processed.
Also, sometimes if there is a comms problem for a server, files will not be
found.
I think I have worked out the problem I was having (it actually consisted of
two problems):
1) I was using the DIR function for two different situations, but at the
same time.
I found a post for VBA Excel which cautioned if the DIR function is used and
then files are scanned in other routines (which is the case for me), then
using the DIR function for another purpose while processing other files will
cause them to 'loose' or 'reset' their location. When I used the code listed,
the file processing stopped working.
--------------------------------------------
** Thanks to Pat Obrien for this **
'Just a quick caution….
If you’re using the DIR command to loop through files, and are calling other
routines to process the files, the other routines cannot have their own DIR
command used in them.
This resets the location that the DIR command looks at and subsequent calls
to DIR in the main routine will fail.'
-----------------------------------------
So from the code I posted earlier, I moved the JLName out of the file
processing loop, and the files started processing again.
F = LCase(Dir("\\" & myClient & "\apps\bkupexec\log\0000.*"))
JLName = ("\\" & myClient & "\apps\bkupexec\log\jljob.dat")
2) Once I did the above, and then tried your code, it worked perfectly - no
errors even if the server does not exist.
Cheers,
GLT.