Shell statement - passing a parameter. 
Author Message
 Shell statement - passing a parameter.

I have a basic shell statement...
  retval = shell("c:\program files\whatever.exe" ,1)

Is there anyway to pass a parameter to the shell statement so it'll execute
different files (for example whoever.exe).

Something like: retval = shell(parameter goes here,1)

Thanks

p.s. Is there a better way to execute a program without using the Shell?



Thu, 29 Mar 2001 03:00:00 GMT  
 Shell statement - passing a parameter.
You are attempting to pass a command line argument. This is quite easy. Do:

Shell("c:\...\whatever.exe someargument(s)", 1)

If you are also the author of whatever.exe then you must parse the argument
using Command$ probably during Sub Main or maybe Form_Load.



Quote:

> I have a basic shell statement...
>   retval = shell("c:\program files\whatever.exe" ,1)

> Is there anyway to pass a parameter to the shell statement so it'll
execute
> different files (for example whoever.exe).

> Something like: retval = shell(parameter goes here,1)

> Thanks

> p.s. Is there a better way to execute a program without using the Shell?



Thu, 29 Mar 2001 03:00:00 GMT  
 Shell statement - passing a parameter.
I read the question a little differently than the first response.  I think
you're asking how to execute "different files", rather than how to pass
switches.

You can write your own routine to do something like that, e.g.,
function myShell(thePath as string) as long
myShell = shell(thePath, 1)
end function

Whether "long" is the right data type for the return value is, as often the
case, left murky by the documentation.

Regarding the second question, OL help for excel 7 says "Use the Shell
function to start an application and set the window style (help for
appactivate), so it looks like you're using the "correct" way.  



Quote:

> Is there anyway to pass a parameter to the shell statement so it'll
execute
> different files (for example whoever.exe).



Thu, 29 Mar 2001 03:00:00 GMT  
 Shell statement - passing a parameter.
function myShell(thePath as string) as long
myShell = shell(thePath,1)
end function



Quote:
> Is there anyway to pass a parameter to the shell statement so it'll
execute
> different files (for example whoever.exe).



Thu, 29 Mar 2001 03:00:00 GMT  
 Shell statement - passing a parameter.

Yeah, that's what I was looking for. Talk about different terminologies...the
other response (which of course was right), I would've used the word argument.
What a great world!

Thanks for all the responses!
  Doug

Quote:
>function myShell(thePath as string) as long
>myShell = shell(thePath,1)
>end function



>> Is there anyway to pass a parameter to the shell statement so it'll
>execute
>> different files (for example whoever.exe).



Thu, 29 Mar 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. pass variable to SHELL statement?

2. VB6 - Problem passing multiple parameters to Command SQL statement

3. Passing Parameter in Select Statement

4. Passing Command line parameters to a shelled program

5. Passing Parameters to the Shell Command

6. Passing parameters to a shelled program?

7. HELP passing parameters to shell

8. Passing parameters to IF-Statement SP

9. Passing Parameters to IF-Statement SP

10. Passing parameters to a shell program

11. passing parameter to a parameter query

12. Passing Parameters to stored parameter queries using VB 5's Data Controls

 

 
Powered by phpBB® Forum Software