Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top