Shell command writes file to wrong directory
I'm calling a command line exe from within Excel 2007 using VBA. The problem
I'm having is the exe outputs a file, e.g. foobar.txt, but it always puts it in the last directory I opened an Excel file from rather than the directory where the exe is being called. For example, say I open a spreadsheet in "c:\excel\worksheet.xls" and in VBA I call an exe in "c:\test\foobar.exe". The file that foobar.exe generates gets copied into "c:\excel" instead of "c:\test" Anyone know what's going on and how to prevent it? thanks, Dustin |
Shell command writes file to wrong directory
You might try using ChDrive and ChDir before Shell'ing to the exe. Either
that or use a BAT file that calls the EXE and in the BAT file use CD to change the current directory. ChDrive "C:\Test" ChDir "C:\Test" Shell "C:\Test\foobar.exe" -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "Dustin" wrote in message ... I'm calling a command line exe from within Excel 2007 using VBA. The problem I'm having is the exe outputs a file, e.g. foobar.txt, but it always puts it in the last directory I opened an Excel file from rather than the directory where the exe is being called. For example, say I open a spreadsheet in "c:\excel\worksheet.xls" and in VBA I call an exe in "c:\test\foobar.exe". The file that foobar.exe generates gets copied into "c:\excel" instead of "c:\test" Anyone know what's going on and how to prevent it? thanks, Dustin |
Shell command writes file to wrong directory
I think that did it, thanks!
"Chip Pearson" wrote: You might try using ChDrive and ChDir before Shell'ing to the exe. Either that or use a BAT file that calls the EXE and in the BAT file use CD to change the current directory. ChDrive "C:\Test" ChDir "C:\Test" Shell "C:\Test\foobar.exe" -- Cordially, Chip Pearson Microsoft MVP - Excel, 10 Years Pearson Software Consulting www.cpearson.com (email on the web site) "Dustin" wrote in message ... I'm calling a command line exe from within Excel 2007 using VBA. The problem I'm having is the exe outputs a file, e.g. foobar.txt, but it always puts it in the last directory I opened an Excel file from rather than the directory where the exe is being called. For example, say I open a spreadsheet in "c:\excel\worksheet.xls" and in VBA I call an exe in "c:\test\foobar.exe". The file that foobar.exe generates gets copied into "c:\excel" instead of "c:\test" Anyone know what's going on and how to prevent it? thanks, Dustin |
All times are GMT +1. The time now is 11:12 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com