ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a .bat file via AppActivate (https://www.excelbanter.com/excel-programming/294773-running-bat-file-via-appactivate.html)

Kevin

Running a .bat file via AppActivate
 
I'm trying to run a .bat file from a macro. I can call
an .exe with no problem (using the same "shell" and
AppActivate" code). I can even call a .exe renamed as
a .bat. If I run it from a command line directly, or even
by double clicking on it, it runs fine. However I cannot
run the .bat from the shell/appactivate combo. Here's the
code I'm using:

varPuttyUpload = Shell("c:\opt_mist1
\ssh\mist1_mist1upload.bat", 0)
AppActivate varPuttyUpload

Watching the locals windows stepping through the macro
shows a return value from the shell function of -610925
(which seems odd).

Changing the trigger from 0 to 1 has no effect. No matter
what I do, I get the following:

"Run-time error '5':
Invalide procedure call or arguement."

If I substitute say "calc.exe" it runs fine.

Any suggestions?

thanx

Kevin

Rob van Gelder[_4_]

Running a .bat file via AppActivate
 
Is that a space after the word opt_mist or just a result of e-mail word
wrapping?

Could try to wrap quotes around it:
varPuttyUpload = Shell("""c:\opt_mist1 \ssh\mist1_mist1upload.bat""", 0)

Another thing is the , 0 in the Shell statement which tells it to Hide the
window (vbHide = 0)
You could try to use normalfocus (1) for testing purposes:
Shell("mycommand", vbNormalFocus)


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Kevin" wrote in message
...
I'm trying to run a .bat file from a macro. I can call
an .exe with no problem (using the same "shell" and
AppActivate" code). I can even call a .exe renamed as
a .bat. If I run it from a command line directly, or even
by double clicking on it, it runs fine. However I cannot
run the .bat from the shell/appactivate combo. Here's the
code I'm using:

varPuttyUpload = Shell("c:\opt_mist1
\ssh\mist1_mist1upload.bat", 0)
AppActivate varPuttyUpload

Watching the locals windows stepping through the macro
shows a return value from the shell function of -610925
(which seems odd).

Changing the trigger from 0 to 1 has no effect. No matter
what I do, I get the following:

"Run-time error '5':
Invalide procedure call or arguement."

If I substitute say "calc.exe" it runs fine.

Any suggestions?

thanx

Kevin





All times are GMT +1. The time now is 09:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com