Run VBS Script from Macro

Does anyone know how I can run a vbs script from a macro. I have been cobbling one toghether but cannot get it to work.

Sub Main()
Dim objShell as Object
Set objShell = _
CreateObject(“WScript.Shell”)
objShell.Exec (“cscript \amhs-ediis1\Ad Hoc Reports\Frank\ED Scheduled Reports\SendmailEDISv2.vbs”)
End Sub

Thanks

Hi Frank,

i believe UNC path is not working well, the script looks fine to me.

did you try a ‘real’ path?

CreateObject("WScript.Shell") objShell.Exec ("cscript c:\SendmailEDISv2.vbs")

Thanks for the reply. Yes, I did try with a mapped drive and still the same.

I am running the macro from the Cognos Scheduler ‘Script file name:’ option in the Results tab. While monitoring the scheduler, I can see a dos window open and shut so I believe Cognos is firing the script. When I run the VBS script manually, it works.

I don’t have series 7 here to test my theory, but I thought I remember that to run through Cognos scripting it mattered what directory the executable resides in. Can you put the macro in the same directory as the reports, or is it already?

oops should have proof read 2 times… I meant to say ‘to run through Cognos Scheduler, it mattered what directory the script executable resides in’.