Run .vbs from a Excel macro?

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
 
G

Guest

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
 
S

Steve Yandl

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
 

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