Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
bhs bhs is offline
external usenet poster
 
Posts: 3
Default Run bat file from excel macro

Hi,

I have a bat file which renames the files in a folder. I am unable to
run this batch file from excel macros. Could anybody help me on this.

Thanks,
Santosh

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default Run bat file from excel macro

Try:

shell(PathAndFilenameOfYourBatFile)

Cheers,
Jason Lepack

bhs wrote:
Hi,

I have a bat file which renames the files in a folder. I am unable to
run this batch file from excel macros. Could anybody help me on this.

Thanks,
Santosh


  #3   Report Post  
Posted to microsoft.public.excel.programming
bhs bhs is offline
external usenet poster
 
Posts: 3
Default Run bat file from excel macro

Hi Jason,

I tried that but its not working. When just double click the bat file,
its working but not through excel macros.

Thanks,
santosh

  #4   Report Post  
Posted to microsoft.public.excel.programming
bhs bhs is offline
external usenet poster
 
Posts: 3
Default Run bat file from excel macro

Mike,

Even this does not work.
what i noticed was, when run this the cmd prompt is in "C:\Documents
and Settings\bhs\My Documents" but my batch file is in C:\.
I used the syntax like this :
Shell Environ("comspec") & " /k C:\ravinu.bat", vbNormalFocus
Where /k helped me freezing the cmd window.

Now i need to get the cmd prompt to "C:" and then execute the batch
file. Can you help me on this.

Thanks,
Santosh

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Run bat file from excel macro

Just a word of caution. Execution of any other code in your workbook will
not
wait until a shell command has completed it will continue.


You can make it wait. See http://www.cpearson.com/excel/shellandwait.htm .
This has two procedures: ShellAndWaitSimple, which just waits for the
process to end, just like every other ShellAndWait routine out there, and
ShellAndWaitEnhanced that lets you display messages to the user as the
shell'd program runs.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Mike" wrote in message
...
bhs,

I'm really not now sure what your question is but if you simply want a
command prompt the syntax is

result = Shell("cmd", 1)

Just a word of caution. Execution of any other code in your workbook wil
not
wait until a shell command has completed it will continue.

Mike



"bhs" wrote:

Mike,

Even this does not work.
what i noticed was, when run this the cmd prompt is in "C:\Documents
and Settings\bhs\My Documents" but my batch file is in C:\.
I used the syntax like this :
Shell Environ("comspec") & " /k C:\ravinu.bat", vbNormalFocus
Where /k helped me freezing the cmd window.

Now i need to get the cmd prompt to "C:" and then execute the batch
file. Can you help me on this.

Thanks,
Santosh




Reply
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
Excel '00, 1st file has macros, how to stop macro in 2nd file? kaptandrews Excel Discussion (Misc queries) 0 May 24th 06 03:07 PM
how can i call macro in powerpoint file from excel file pm[_2_] Excel Programming 3 January 6th 06 10:40 PM
Macro to save Excel file with date and time in the file name? sonic_d_hog Excel Programming 2 January 5th 06 05:57 PM
Creating a new excel file from an existing file using macro Macro Excel Programming 2 July 28th 05 06:40 PM
VBA Macro to copy an column from one Excel file into another file Sam Excel Programming 4 July 3rd 05 03:36 AM


All times are GMT +1. The time now is 01:24 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"