0

I would like to have a macro in Outlook 2010 that will run a vbscript on my local drive. Here's what I've tried.

Sub RUNvbscript()
Shell "Explorer.exe ""C:\rest of path""", 1
End Sub

That did not work, any suggestions?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
mcadamsjustin
  • 297
  • 4
  • 11
  • 23

1 Answers1

0

You have a few options here: Shell(), the ShellExecute() API function, scripting host's WShell.Run(), etc. If you need to wait for your script to complete, however, WShell.Run() has a synchronous option, which makes it nice.

strPath = "c:\folder\myscript.vbs"
Set objShell = CreateObject("WScript.Shell")

' Run synchronously...
objShell.Run Chr(34) & strPath & Chr(34), 1, True

' Or, run asynchronously...
objShell.Run Chr(34) & strPath & Chr(34), 1, False

With the others, you'd need to use WaitForSingleObject or some other polling mechanism to determine when the script completes.

Bond
  • 16,071
  • 6
  • 30
  • 53