I'm struggling to figure out what I'm doing wrong here...
I have two instances that I need to execute a batch file from my VBA code. The first one is working, but I can't get the second one to work. I keep getting the error "Method 'Run' of object 'IWshShell3' failed".
This is the code:
Set WSHs = CreateObject("WScript.Shell")
shResults = WSHs.Run("""C:\Documents and Settings\apprss\Desktop\Faxes\Returns\412072459-R.bat""", , True)
which I found on one of the posts on this site, but I've also tried:
Set WSHs = CreateObject("WScript.Shell")
WSHs.Run Chr(34) & varBatFile & Chr(34), , True
where "varBatFile" contains the full path and file name of the batch file to be executed. The batch file contains:
"C:\Documents and Settings\apprss\Desktop\Faxes\Returns\txt2pdf.exe" "C:\Documents and Settings\apprss\Desktop\Faxes\Returns\412072459-R.rpt" "C:\Documents and Settings\apprss\Desktop\Faxes\Returns\412072459-R.pdf" -pwa -pol90 -lpp56 -pfs9
This is a call to txt2pdf, which will convert a text document I'm creating (on the fly) to a PDF. When I execute this batch script manually, it works fine.
I'm thinking it's not the VBA code, and not something in my batch file, but when I use the two together, something gets hosed up.
All assistance is greatly appreciated! I've been beating my head against the wall for hours now!
Thanks!
Scott
I have two instances that I need to execute a batch file from my VBA code. The first one is working, but I can't get the second one to work. I keep getting the error "Method 'Run' of object 'IWshShell3' failed".
This is the code:
Set WSHs = CreateObject("WScript.Shell")
shResults = WSHs.Run("""C:\Documents and Settings\apprss\Desktop\Faxes\Returns\412072459-R.bat""", , True)
which I found on one of the posts on this site, but I've also tried:
Set WSHs = CreateObject("WScript.Shell")
WSHs.Run Chr(34) & varBatFile & Chr(34), , True
where "varBatFile" contains the full path and file name of the batch file to be executed. The batch file contains:
"C:\Documents and Settings\apprss\Desktop\Faxes\Returns\txt2pdf.exe" "C:\Documents and Settings\apprss\Desktop\Faxes\Returns\412072459-R.rpt" "C:\Documents and Settings\apprss\Desktop\Faxes\Returns\412072459-R.pdf" -pwa -pol90 -lpp56 -pfs9
This is a call to txt2pdf, which will convert a text document I'm creating (on the fly) to a PDF. When I execute this batch script manually, it works fine.
I'm thinking it's not the VBA code, and not something in my batch file, but when I use the two together, something gets hosed up.
All assistance is greatly appreciated! I've been beating my head against the wall for hours now!
Thanks!
Scott