checking for folder existance

N

Nathan

I have the following code attached to a button which opens
a folder "\\[server]\...\[model #]\[serial #]" using
internet explorer.

Private Sub Command148_Click()

Dim stAppName As String
Dim sModelNum As String
Dim sSerialNum As String

'Then some code to assign sModelNum and sSerialNum the
correct values.

stAppName = "C:\Program Files\Internet
Explorer\IEXPLORE.EXE \\Sfrkda01\Crane_Data\Crane DB
linked Data\" & sModelNum & "\" & sSerialNum
Call Shell(stAppName, 1)

End Sub

What I would like to do is check to see if the folder
exists before opening explorer. If the Serial # folder
doesn't exist, I'd like to open the Model # folder. If
neither exist, I'd like to open the "Crane DB linked Data"
folder. How do I perform the check to see if the folder
exists?

Thanks!
Nathan
 
B

Bruce M. Thompson

What I would like to do is check to see if the folder
exists before opening explorer. If the Serial # folder
doesn't exist, I'd like to open the Model # folder. If
neither exist, I'd like to open the "Crane DB linked Data"
folder. How do I perform the check to see if the folder
exists?

Use the "Dir()" function. You need to include the "vbDirectory" attribute.

If Dir("c:\Void",vbDirectory) = ""
'The specified directory does not exist
Else
'The specified directory does exist
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