Run batch file from VBA

  • Thread starter Thread starter reclusive monkey
  • Start date Start date
R

reclusive monkey

I have writtent the most very basic of batch files to list all .xls
files in a directory to a text file;

dir /B *.xls > list.txt

I then import this list of the files into my spreadsheet. Can I run
this batch file from VBA? I am using Excel 2002 (10.6501.6626) SP3
(Office XP) and I am on Windows 2000 Professional. I am sure this is
pretty straightforward, but my googling skills just can't find the
answer! Anyone point me to the answer, or set me on the right track?
Thanks
 
May want to try
Shell "CMD /c dir /B *.xls > list.txt"
or
Shell "c:\winnt\command.com /c dir /B *.xls > list.txt"

depending on where command.com lives

Kevin Beckham
 
Kevin Beckham said:
May want to try
Shell "CMD /c dir /B *.xls > list.txt"
or
Shell "c:\winnt\command.com /c dir /B *.xls > list.txt"

Thanks Tom and Kevin, that's worked a treat.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top