![]() |
procedure call error issue
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 |
procedure call error issue
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) "Student" wrote in message ... 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 |
procedure call error issue
thank you!
"Chip Pearson" wrote: 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) "Student" wrote in message ... 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 |
All times are GMT +1. The time now is 01:32 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com