procedure call error issue

S

Student

Hello All, Thank you... up front, for what you do is greatly appreciated !

i want to execute a shell; however, the shell resides in multiple locations
and i want to set the path in an IF statement then append it to the name of
the
bat file

If LOBTitle = "doc" then
path = "\\snt27\Pro\FTP\"
elseif LOBTitle = "fac" then
path = "\\snt28\PEM\FTP\"
endif
pathName = path & "run_ftp.bat"
RetVal = Shell(pathName, 1)

the problem is I get a procedure call error when using "pathName" variable
instead of the exact path?

please help
thank you again
 
C

Chip Pearson

I can't replicate your problem. The following code works for me:

Sub AAA()
Dim Path As String
Dim X As Boolean
Dim DirRes As String

X = True
If X = True Then
Path = "\\DellLapTop\MainDrive\"
Else
Path = "\\Dell8250\MainDrive\"
End If

On Error Resume Next
Err.Clear
DirRes = Dir(Path, vbDirectory)
If Err.Number <> 0 Then
Debug.Print "Drive or server does not exist.", Err.Number,
Err.Description
Else
If DirRes = vbNullString Then
Debug.Print "Drive Not Found: " & Path
Else
Debug.Print "Drive Found: " & Path
End If
End If

End Sub

You'll get an error if the network resource cannot be found or is
unavailable. Are you sure your servers and shares are available?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 
S

Student

thank you!

Chip Pearson said:
I can't replicate your problem. The following code works for me:

Sub AAA()
Dim Path As String
Dim X As Boolean
Dim DirRes As String

X = True
If X = True Then
Path = "\\DellLapTop\MainDrive\"
Else
Path = "\\Dell8250\MainDrive\"
End If

On Error Resume Next
Err.Clear
DirRes = Dir(Path, vbDirectory)
If Err.Number <> 0 Then
Debug.Print "Drive or server does not exist.", Err.Number,
Err.Description
Else
If DirRes = vbNullString Then
Debug.Print "Drive Not Found: " & Path
Else
Debug.Print "Drive Found: " & Path
End If
End If

End Sub

You'll get an error if the network resource cannot be found or is
unavailable. Are you sure your servers and shares are available?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com
(email address is on the web site)
 

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