Need correct syntax for opening VBS script from within Microsoft Access.

stephenlecomptejr
stephenlecomptejr used Ask the Experts™
on
Opening a vbs script from within Microsoft Access VBA - I get the error run-time error - Invalid procedure or call or argument.
with the yellow highlight on:  Shell "" & sOpenFileLocal & "", vbNormalFocus

Shell "" & sOpenFileLocal & "", vbNormalFocus
      DoEvents
      CurrentProject.Application.DoCmd.Quit
      Exit Function

Open in new window

eequestion.PNG
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You need to call a command with Shell like:

cscript yourscript.vbs

Open in new window

IT / Software Engineering Consultant
Top Expert 2016
Commented:
And if you want it to run in Window mode rather than command line then do:

wscript yourscript.vbs

And if your file path for the VBS file could contain spaces then do:

sVbsPath = "C:\temp\my file.vbs"
sOpenFileLocal = "cscript """ & sVbsPath & """"
Shell sOpenFileLocal, vbNormalFocus

Open in new window


»bp

Author

Commented:
Bill how can I open it without the windows command prompt coming up?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I don't want it to run in Windows mode I guess.

Author

Commented:
never mind I see to change Cscript to Wscript...
thanks.

Author

Commented:
Thank you both for your comments.
Bill PrewIT / Software Engineering Consultant
Top Expert 2016

Commented:
Welcome.


»bp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial