Last active
September 20, 2015 02:02
-
-
Save danwagnerco/dfb6e9051412a04f7266 to your computer and use it in GitHub Desktop.
This script runs a batch file from VBA using the WshShell object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" & _ | |
Chr(34) | |
lngErrorCode = wsh.Run(strCommand, _ | |
WindowStyle:=0, _ | |
WaitOnReturn:=True) | |
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