Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Call .BAT file with paramaters using Excel

I want to call a .bat file with parameters using MS Excel. I tried both the
Shell command and Hyperlink but neither one will work when I try to pass
paramaters to the .bat file. For example if I use the following shell
command without parameters it works:

dim reset
reset = shell( "c:\reset-code.bat",1)

However, when I add my 4 parameters it does not work:
reset = shell("c:\reset-code.bat 2009 2008 Y:\account 19",1)

Has anyone run into this one?

Thanks in advance!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Call .BAT file with paramaters using Excel

This worked for me:

Sub RuntestProgram()
Dim program As String
program = "C:\Delete\test.bat fred"
TaskID = Shell(program)
End Sub


where test.bat was simply

copy C:\Delete\text.txt C:\Delete\%1.txt

It created the file fred.txt, a copy of text.txt

--
HTH,
Bernie
MS Excel MVP


"CraigKer" wrote in message
...
I want to call a .bat file with parameters using MS Excel. I tried both the
Shell command and Hyperlink but neither one will work when I try to pass
paramaters to the .bat file. For example if I use the following shell
command without parameters it works:

dim reset
reset = shell( "c:\reset-code.bat",1)

However, when I add my 4 parameters it does not work:
reset = shell("c:\reset-code.bat 2009 2008 Y:\account 19",1)

Has anyone run into this one?

Thanks in advance!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Call .BAT file with paramaters using Excel

Hi Craig

You code is fine.

Please check your .bat file for (4 parameters, path mentioned, file
extension mentioned etc; ) If you cannot find an issue paste your code and we
will have a look at it

If this post helps click Yes
--------------
Jacob Skaria


"CraigKer" wrote:

I want to call a .bat file with parameters using MS Excel. I tried both the
Shell command and Hyperlink but neither one will work when I try to pass
paramaters to the .bat file. For example if I use the following shell
command without parameters it works:

dim reset
reset = shell( "c:\reset-code.bat",1)

However, when I add my 4 parameters it does not work:
reset = shell("c:\reset-code.bat 2009 2008 Y:\account 19",1)

Has anyone run into this one?

Thanks in advance!!

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
uisng two paramaters for conditional formatting / Limiting screen size Colin Hayes Excel Discussion (Misc queries) 4 May 20th 07 05:32 PM
Can Paramaters be used w/ OLE SQL Query & Excel Nodak Excel Programming 2 March 18th 06 05:38 PM
Call a batch file from an Excel Macro Gary''s Student Excel Discussion (Misc queries) 0 March 2nd 06 03:26 PM
how can i call macro in powerpoint file from excel file pm[_2_] Excel Programming 3 January 6th 06 10:40 PM
Call procedure from another Excel File? Dave Ladd Excel Programming 1 September 27th 05 07:52 PM


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