PC Review


Reply
Thread Tools Rate Thread

Call .BAT file with paramaters using Excel

 
 
CraigKer
Guest
Posts: n/a
 
      20th Mar 2009
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 With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      20th Mar 2009
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" <(E-Mail Removed)> wrote in message
news:C9BC5A1A-C666-483D-AB2F-(E-Mail Removed)...
>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 With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      20th Mar 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Excel workbook to Excel - Test Paramaters and data anna_717717 Microsoft Access Database Table Design 0 6th May 2008 07:11 PM
Pass paramaters to an Access mde file JohnConklin Microsoft Access 0 26th Jun 2006 09:45 PM
Can Paramaters be used w/ OLE SQL Query & Excel =?Utf-8?B?Tm9kYWs=?= Microsoft Excel Programming 2 18th Mar 2006 05:38 PM
how can i call macro in powerpoint file from excel file pm Microsoft Excel Programming 3 6th Jan 2006 10:40 PM
Call procedure from another Excel File? =?Utf-8?B?RGF2ZSBMYWRk?= Microsoft Excel Programming 1 27th Sep 2005 07:52 PM


Features
 

Advertising
 

Newsgroups
 


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