Hello. This is my first post on DreamInCode. I've been programming for a while, but don't have any formal training in it, just what I've gotten from reading some books.
I'm trying to call a batch file from Excel. The batch file produces some other text files that I eventually want to read back into Excel. While the call to the batch file seems to work (a command window opens and a bunch of text flies by), the files that should be generated never appear. Here's my VBA code in Excel for calling the batch file:
CODE
Private Sub Run_Prog_Bttn_Click()
Dim Test As Double
Dim Response As VbMsgBoxResult
Test = Shell("D:\TestRunforCall\TestRun.bat", vbNormalFocus)
If Test = 0 Then
Response = MsgBox("The Specified Batch File Does Not Exist.", vbOKOnly, "File Error")
Exit Sub
ElseIf Test > 0 Then
Response = MsgBox("Successful call to Batch File.", vbOKOnly, "File Run Report")
End If
End Sub
Everytime I click the button to call this Sub, the "Successful call to Batch File" message appears.
If I go to the folder where the batch file is located, I can double-click it and it runs fine, putting the files it generates into the folder with the batch file. So I know the contents of the batch file are correct. Something just isn't right with the Excel call.
Can anyone help me to understand why it's not working? I've looked all over and the files aren't being written anywhere else. They're just not being written at all.
Also, if it would be better to post this in one of the other forums, please let me know. After looking at their names, this one seemed to be the best place.
Thanks for any help you can share!
Sean
This post has been edited by sjc: 16 Aug, 2007 - 04:10 PM