Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default send parameters to a batch file with the shell command

Hi,
I've tried succesfully to call a batch macro from excel with the shell
command.
But when I add parameters to the shell pathname it does not work.

assume the batch file x.bat content is:
echo year is %1
pause

The following works well:
Dim RetVal
mycmd = "C:\temp\x.bat"
RetVal = Shell(mycmd, 1)

but:
Dim RetVal
mycmd = "C:\temp\x.bat 2006"
RetVal = Shell(mycmd, 1)

does not work.

Any help will be appreciated
Marcos

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default send parameters to a batch file with the shell command

Dim RetVal
mycmd = "C:\temp\x.bat 2006"
RetVal = Shell(mycmd, 1)

works by me!

x.bat contains 1 line:
echo %1

--
AP

"Marcos" a écrit dans le message de news:
...
Hi,
I've tried succesfully to call a batch macro from excel with the shell
command.
But when I add parameters to the shell pathname it does not work.

assume the batch file x.bat content is:
echo year is %1
pause

The following works well:
Dim RetVal
mycmd = "C:\temp\x.bat"
RetVal = Shell(mycmd, 1)

but:
Dim RetVal
mycmd = "C:\temp\x.bat 2006"
RetVal = Shell(mycmd, 1)

does not work.

Any help will be appreciated
Marcos



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default send parameters to a batch file with the shell command

Ardus
Thanks, it did work for me as well...
My real problem was calling a macro in the directory C:\Documents and
Settings\Marcos\Desktop\temp.
For the email i wrote c:\temp to simplify, but and as I tried with
c:\temp it did work as you said.

This helped me workout the solution. I was running
mycmd= "C:\Documents and Settings\Marcos\Desktop\temp\x.bat 2006"
RetVal = Shell(mycmd, 1)
it seems a double quetes were needed for the path above.
Adding:
mycmd= chr$(34)+"C:\Documents and
Settings\Marcos\Desktop\temp\x.bat"+chr$(34)+" 2006"
did the trick.
thanks for the help,
Marcos

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default send parameters to a batch file with the shell command

maybe one more "

mycmd= """C:\Documents and Settings\Marcos\Desktop\temp\x.bat"" 2006"
? mycmd
"C:\Documents and Settings\Marcos\Desktop\temp\x.bat" 2006

--
Regards,
Tom Ogilvy

"Ardus Petus" wrote in message
...
You could have written:
mycmd= ""C:\Documents and Settings\Marcos\Desktop\temp\x.bat"" 2006"

HTH
--
AP

"Marcos" a écrit dans le message de news:
...
Ardus
Thanks, it did work for me as well...
My real problem was calling a macro in the directory C:\Documents and
Settings\Marcos\Desktop\temp.
For the email i wrote c:\temp to simplify, but and as I tried with
c:\temp it did work as you said.

This helped me workout the solution. I was running
mycmd= "C:\Documents and Settings\Marcos\Desktop\temp\x.bat 2006"
RetVal = Shell(mycmd, 1)
it seems a double quetes were needed for the path above.
Adding:
mycmd= chr$(34)+"C:\Documents and
Settings\Marcos\Desktop\temp\x.bat"+chr$(34)+" 2006"
did the trick.
thanks for the help,
Marcos







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default send parameters to a batch file with the shell command

Sure!

--
AP

"Tom Ogilvy" a écrit dans le message de news:
...
maybe one more "

mycmd= """C:\Documents and Settings\Marcos\Desktop\temp\x.bat"" 2006"
? mycmd
"C:\Documents and Settings\Marcos\Desktop\temp\x.bat" 2006

--
Regards,
Tom Ogilvy

"Ardus Petus" wrote in message
...
You could have written:
mycmd= ""C:\Documents and Settings\Marcos\Desktop\temp\x.bat"" 2006"

HTH
--
AP

"Marcos" a écrit dans le message de news:
...
Ardus
Thanks, it did work for me as well...
My real problem was calling a macro in the directory C:\Documents and
Settings\Marcos\Desktop\temp.
For the email i wrote c:\temp to simplify, but and as I tried with
c:\temp it did work as you said.

This helped me workout the solution. I was running
mycmd= "C:\Documents and Settings\Marcos\Desktop\temp\x.bat 2006"
RetVal = Shell(mycmd, 1)
it seems a double quetes were needed for the path above.
Adding:
mycmd= chr$(34)+"C:\Documents and
Settings\Marcos\Desktop\temp\x.bat"+chr$(34)+" 2006"
did the trick.
thanks for the help,
Marcos







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default send parameters to a batch file with the shell command

Thanks to all
it's much easier the way you say

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
getting vba shell command to execute batch and save output to a file Mad Scientist Jr Excel Programming 2 April 28th 06 03:00 PM
Shell command ignores parameters Pete[_22_] Excel Programming 2 February 15th 05 08:07 AM
Shell command ignores parameters Pete[_22_] Excel Programming 0 February 8th 05 04:39 PM
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


All times are GMT +1. The time now is 02:41 PM.

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

About Us

"It's about Microsoft Excel"