Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running an external .vbs file from within Access 1

Status
Not open for further replies.

SlakeB

MIS
Jun 15, 2005
40
US
Does anyone know how I can run an external .vbs file from within Access (With a button on an Access form triggering a macro)?
 
Something like this ?
CreateObject("WScript.Shell").Run "\path\to\script.vbs"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
OR....

Call Shell("wscript.exe" & " c:\test.vbs", vbMaximizedFocus)
 
I put this code behind my form button:

Private Sub Command4_Click()
Call Shell("wscript.exe" & "C:\test.vbs", vbMaximizedFocus)
End Sub

I keep getting a file not found error.
Am I missing something?

 
Well, do you actually have a file at the root of C: that is named test.vbs?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Aaah...I see the problem. Change the line to:
Call Shell("wscript.exe " & "C:\test.vbs", vbMaximizedFocus)

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Thanks that worked. That's odd that a space is required after wscript.exe.
 
It's not really all that odd. All you are doing is concatenating two strings. So, before you were saying "Run wscript.exeC:\test.vbs". Which is clearly wrong. With the space you are saying "Run wscript.exe C:\test.vbs". Which is right.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top