Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
rci rci is offline
external usenet poster
 
Posts: 40
Default Passing argument to excel

Hi all...

Interesting task here...

I am using a Visual Basic app (NOT excel) to send a Shell() command that
launches an excel sheet:

"C:\MySheets\Go.xls"

Windows finds Excel, loads the Go.xls sheet, and all is well...

Here is the issue: I wish to pass an argument ALONG with this shell command
that can be "seen" by Go.xls

For example, I'd like to have this work:

Result = Shell("C:\Mysheets\Go.xls " & iArgument)

(where iArgument is an integer variable)


A macro in Go.xls would need the iArgument to know what to do...
Is there a way to accomplish this?

Thanks so much!

M
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Passing argument to excel

Stephen Bullen Posted:
I have a menu item which reads:

"C:\Office95\Office\EXCEL.EXE" "D:\book2.xls" /e/param1/param2

In book2.xls, I have:

Declare Function GetCommandLine Lib "kernel32" Alias "GetCommandLineA"
() As String

Sub Workbooks_Open()

Dim s As String, i As Integer

s = GetCommandLine

i = InStr(1, s, "/e")

MsgBox Mid(s, i + 2, 200)

End Sub

When I run it, I get a message box saying "/param1/param2". Works for
Excel 95 and 97. The key is to use the (valid) /e parameter, but tack
on your other parameters afterwards. Note that you can't use spaces in
your parameters, even if they are in strings.

----------------------

Guess you would have to test it to see if it works for you.
--
Regards,
Tom Ogilvy

"rci" wrote in message
...
Hi all...

Interesting task here...

I am using a Visual Basic app (NOT excel) to send a Shell() command that
launches an excel sheet:

"C:\MySheets\Go.xls"

Windows finds Excel, loads the Go.xls sheet, and all is well...

Here is the issue: I wish to pass an argument ALONG with this shell

command
that can be "seen" by Go.xls

For example, I'd like to have this work:

Result = Shell("C:\Mysheets\Go.xls " & iArgument)

(where iArgument is an integer variable)


A macro in Go.xls would need the iArgument to know what to do...
Is there a way to accomplish this?

Thanks so much!

M



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 400
Default Passing argument to excel

AS you are already using VB, there is an easier way than using Shell (I don't
think it allows arbitrary command line arguments):

set xl = CreateObject("Excel.Application")
xl.Workbooks.Open "c:\mysheets\go.xls"
xl.visible = true
xl.Run "xx(78)"
set xl = nothing

where xx is a public macro in a module and 78 is an integer being passed to
it.

"rci" wrote:

Hi all...

Interesting task here...

I am using a Visual Basic app (NOT excel) to send a Shell() command that
launches an excel sheet:

"C:\MySheets\Go.xls"

Windows finds Excel, loads the Go.xls sheet, and all is well...

Here is the issue: I wish to pass an argument ALONG with this shell command
that can be "seen" by Go.xls

For example, I'd like to have this work:

Result = Shell("C:\Mysheets\Go.xls " & iArgument)

(where iArgument is an integer variable)


A macro in Go.xls would need the iArgument to know what to do...
Is there a way to accomplish this?

Thanks so much!

M

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
Passing a UDF as an argument to a UDF puff Excel Discussion (Misc queries) 3 February 23rd 06 09:46 PM
Passing argument to another Sub Roman Excel Programming 6 February 1st 05 09:17 PM
?Passing argument/parameter just starting[_2_] Excel Programming 0 October 23rd 04 07:56 PM
Passing range as argument Jan Kronsell[_2_] Excel Programming 3 September 3rd 03 12:31 PM
Passing an argument to a quote Zach Excel Programming 1 July 25th 03 01:00 AM


All times are GMT +1. The time now is 08:17 AM.

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"