Hi All
I am having problems running a batch file from excel vba using the shell command. The cmd windows appears briefly but it does not download the file following the commands in the batch file. When I run it manually it works fine so I know the batch commands are OK. my vba code is
Please note I have modified the file paths to censor information.
Can anyone offer any assistance ?
I am having problems running a batch file from excel vba using the shell command. The cmd windows appears briefly but it does not download the file following the commands in the batch file. When I run it manually it works fine so I know the batch commands are OK. my vba code is
Code:
Sub modTXTFile()
Dim sFile As String
Dim sText As String
Dim iFileNum As Integer
Dim wsh As Object
Dim statusnum As String
sFile = "S:\mypath\Files.bat"
sText = Workbooks("File.xls").Sheets("sheet1").Range("o1").Value
iFileNum = FreeFile
Open sFile For Output As iFileNum
Print #iFileNum, sText
Close #iFileNum
Set wsh = CreateObject("WScript.Shell")
statusnum = wsh.Run(Command:="%comspec% /c " & "S:\MyPath\Files.bat", WindowStyle:=5, waitonreturn:=True)
Please note I have modified the file paths to censor information.
Can anyone offer any assistance ?