Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This script runs a batch file from VBA using the WshShell object
Option Explicit
Public Sub RunBatchFile()
Dim strCommand As String
Dim lngErrorCode As Long
Dim wsh As WshShell
Set wsh = New WshShell
'Run the batch file using the WshShell object
strCommand = Chr(34) & _
"C:\wshshell-fun\Create New 2015 Project Folder.bat" & _
lngErrorCode = wsh.Run(strCommand, _
WindowStyle:=0, _
If lngErrorCode <> 0 Then
MsgBox "Uh oh! Something went wrong with the batch file!"
Exit Sub
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment