File Does Not Exist Code - Improve functionality

JohnLee

Registered User.
Local time
Today, 09:11
Joined
Mar 8, 2007
Messages
692
Good Morning Folks,

I have this bit of code that if the file path does not exist it ends the process, but what I would like it to do is to not end the process but continue to the next record. If someone wouldn't mind looking at the code below and give any suggestions or pointers that would be most appreciated.

Code:
If Not FS.FolderExists(TifFilePath) Then
      MsgBox "Folder Doesn't Exist", , "Reading Tif Files"
      End
End If

Regards

John
 
well simply comment out the code and keep running? Possibly adding any following code into the else part of the if?
Code:
If Not FS.FolderExists(TifFilePath) Then
'      MsgBox "Folder Doesn't Exist", , "Reading Tif Files"
'      End
else 
'insert the rest of the code here.
End If
Alternatively reverse the if and actually execute code there, then move to the next record after (not) executing the code.
Code:
If FS.FolderExists(TifFilePath) Then
'insert the rest of the code to execute here.

End If
rs.movenext
 
Hi,

Thanks for your response, commenting or removing the code was my initial thoughts, but I would still like to know that the folder the folder doesn't exist, because I can then investigate after the process has completed.

Thanks again

Regards
 
You can store the folder/file into a variable and use that variable to stack the names/folders and msgbox or whatever it out.
 
Hi,

Thanks for that, I give that a go.

Regards
 
Re: File Does Not Exist Code - SharePoint File

Hi, I am new the VBA. I am wondering if someone can help me with VBA code to check if a SharePoint file exists, and if it does exist, continue on. But if it does not exist, have a pop up message indicating "No File". All the file are in different folders to correspond to different facilities. I have used the code:

Dim sFile As String
sFile ="//sharepoint file.docx"
If Len(Dir$(sFile)) <> "" Then
MsgBox "File not there"
Exit Sub
End If

But I get error 53, "File Not Found" on the 3rd line. Can someone please let me know how I can correct this, or perhaps use something different. Any help would be greatly appreciated.
 

Users who are viewing this thread

Back
Top Bottom