Run .vbs from a Excel macro?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi guys!

I need to run a .vbs scrpit from inside a excell macro. (the script opens
phostoshop, does several actions, makes some files... and closes..)

How can i do this??

Thnks a lot!!
SpeeD
 
hi again!

The command works fine with an EXE, but give an "invalid preocedure" with my
test.vbs file.
Is there a way to go round this problem?

Thanks
SpeeD72
 
The executable for running scripts is either Wscript.exe or Cscript.exe,
both located in the system32 folder. Something like:

Sub RunAscript()
Dim RetVal
RetVal = Shell("C:\Windows\System32\WScript.exe C:\Test\myScript.vbs", 0)
End Sub

would run the script "C:\Test\myScript.vbs" using Shell.

I think I'd create an instance of the Scripting Runtime in Excel and just
incorporate the code from the script inside the VBA routine rather than
launch a separate script. If you use Shell, you can't be sure that the
script will have finished what it's supposed to do before the rest of your
code runs.

Steve
 
Back
Top