Directory

S

Steve Yandl

There may be a better way in VBA but I generally create an instance of the
object "Scripting.FileSystemObject" and use its 'FolderExists' method to
return the information as a boolean.

Steve
 
D

Doug Robbins - Word MVP

Hi Karine,

ChDir will throw Error 76 if the directory does not exist.

On Error GoTo Reason
ChDir "D:\Tmp"
Reason:
If Err = 76 Then 'Path not found
MsgBox "The Directory does not exist."
Exit Sub
End If


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
E

Eric

Put this in your code:

Len(Dir("C:\yourfolder\))<> 0 'Path exists
Len(Dir("C:\yourfolder\))= 0 ' Path does not exist

Eric
 

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