LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default getting vba shell command to execute batch and save output to a file

I have a batch file I would like to execute from an Excel macro, and
have the output be piped to a file. For this test I created a file
"dir.bat" in the same folder as "Book1.xls", the file contains one
line, "dir /b /o"

From the command prompt, if I run it like so


dir.bat dir.txt

it successfully saves the directory listing to "dir.txt".

However it doesn't seem to be working from the Excel macro:

Sub ShellTest()
Shell ThisWorkbook.Path & "\dir.bat dir.txt"
End Sub

I get no error messages, and dir.txt gets created, but it is empty.

Can anyone see anything wrong?

Much appreciated...

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Function - Execute DOS Command bill_morgan Excel Programming 6 September 18th 05 10:11 AM
Shell command and exe file conundrum Greg Wilson[_4_] Excel Programming 2 September 4th 04 09:24 PM
Batch file in Shell Function Eric[_14_] Excel Programming 2 November 14th 03 11:08 PM
Execute a batch file from inside Excel Eric[_14_] Excel Programming 2 November 12th 03 05:21 PM
Copying a file with VBA (or with a SHELL command) Franck V. Excel Programming 1 September 15th 03 07:46 PM


All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"