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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I call a .VBS script using VBA code?

Status
Not open for further replies.

Apollo6

Technical User
Jan 27, 2000
418
US
I am using the following code which works for a batch file (.bat) but not (.vbs):

Private Sub cmdButton1()
Shell "D:\Some_Directory\CreateFTPscript.vbs", 1
End Sub

Thanks in advance for any help.
 
For anyone to see if they need to do this, I found this in another forum:

Sub Run_VBS_File()

Dim WshShell

Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "C:\Some_directory\Script.vbs"

End Sub

Just call the procedure...
 
alternatively, you could have a look at the ShellExecute API call

ex.,

Option Explicit

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub RunScript()
Call ShellExecute(0&, vbNullString, "C:\input.vbs", vbNullString, vbNullString, 0)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top