Path Not Found error with fso.getfolder

B

Brad

Here is the code:

Set objfso = CreateObject("Scripting.FileSystemObject")
objstartfolder = "d:\apps\database documents\" & folder

Set objfolder = objfso.GetFolder(objstartfolder)


I have used this code for months with no problems. Now I get Path Not
Found error everytime I try to run it. I assume there is some
problems with the folder name somewhere. I need either a fix or a
work around that will allow the code to continue to run. Is there a
way to do If path exists then ... or some other way to avoid this
error.

Thanks in advance.
Brad
 
O

OssieMac

Hi Brad,

Do I interpret your question correctly in that you are looking for a way to
handle the error if incorrect path? If so, then try the following:-

Set objfso = CreateObject("Scripting.FileSystemObject")

objstartfolder = "d:\apps\database documents\" & folder

On Error Resume Next
Set objfolder = objfso.GetFolder(objstartfolder)
On Error GoTo 0

If Not objfolder Is Nothing Then 'Path is valid
MsgBox folder & " found"
Else
MsgBox folder & " NOT found." & Chr(13) & _
"Check path and folder name."
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top