command line startup options

M

msnews

I have a workbook with four sheets. I'd like to create a shortcut for each
of four users that opens to their sheet and performs an action.

After reading about Command() and the GetCommandLineA API I'm still stuck.
GetCommandLineA crashes when run during Excel startup and only returns the
workbook path/name when run from the VBA IDE.

Is there a way to open a workbook depending upon passed in parameters?
 
M

msnews

msnews said:
I have a workbook with four sheets. I'd like to create a shortcut for each
of four users that opens to their sheet and performs an action.

After reading about Command() and the GetCommandLineA API I'm still stuck.
GetCommandLineA crashes when run during Excel startup and only returns the
workbook path/name when run from the VBA IDE.

Is there a way to open a workbook depending upon passed in parameters?

Sorry, we're using Excel 2003
 
J

Jim Rech

How about a simple macro that checks the user's name and switches to the
right sheet when the workbook opens?:

This goes in the ThisWorkbook module.

Private Sub Workbook_Open()
Select Case Application.UserName
Case "Joe"
Sheet1.Activate
Case "Sally"
Sheet2.Activate
'...
End Select
End Sub


--
Jim
|
| | >I have a workbook with four sheets. I'd like to create a shortcut for
each
| >of four users that opens to their sheet and performs an action.
| >
| > After reading about Command() and the GetCommandLineA API I'm still
stuck.
| > GetCommandLineA crashes when run during Excel startup and only returns
the
| > workbook path/name when run from the VBA IDE.
| >
| > Is there a way to open a workbook depending upon passed in parameters?
| >
| >
|
| Sorry, we're using Excel 2003
|
|
 
M

msnews

Jim Rech said:
How about a simple macro that checks the user's name and switches to the
right sheet when the workbook opens?:

This goes in the ThisWorkbook module.

Private Sub Workbook_Open()
Select Case Application.UserName
Case "Joe"
Sheet1.Activate
Case "Sally"
Sheet2.Activate
'...
End Select
End Sub

Jim,

Thanks, but in my post I was trying to simplify my needs and wasn't entirely
accurate in my description (my bad).

The need is to open the same file four times on the same PC, each in it's
own instance of Excel. Specifically we want to have multiple monitors each
display a different sheet of said file. The request is predominantly about
how to pass a startup option to excel from the command line.

Thanks for the help.
 
J

Jim Rech

Excel does not have a lot of command line options but a file name is one.
So you could open a specific workbook with a shortcut like this:

C:\mso\mso03\OFFICE11\EXCEL.EXE c:\book1.xls

This will open a new Excel instance with each execution (or it does for me).
After the first opening though you do get warned that the workbook is
already open.

You can open a file read-only like this:

C:\mso\mso03\OFFICE11\EXCEL.EXE /r C:\book1.xls

A shortcut to the workbook directly: C:\Book1.xls (w/o Excel.exe on the
command line), would likely use the same Excel instance (depends on your
registry file associations but the default is to use the same instance).

Another approach is to run a script to start Excel and load a workbook via
automation. This gives you more control over the process if you need it.

--
Jim
|
| | > How about a simple macro that checks the user's name and switches to the
| > right sheet when the workbook opens?:
| >
| > This goes in the ThisWorkbook module.
| >
| > Private Sub Workbook_Open()
| > Select Case Application.UserName
| > Case "Joe"
| > Sheet1.Activate
| > Case "Sally"
| > Sheet2.Activate
| > '...
| > End Select
| > End Sub
| >
| >
| > --
| > Jim
|
| Jim,
|
| Thanks, but in my post I was trying to simplify my needs and wasn't
entirely
| accurate in my description (my bad).
|
| The need is to open the same file four times on the same PC, each in it's
| own instance of Excel. Specifically we want to have multiple monitors
each
| display a different sheet of said file. The request is predominantly
about
| how to pass a startup option to excel from the command line.
|
| Thanks for the help.
|
|
 
M

msnews

Another approach is to run a script to start Excel and load a workbook via
automation. This gives you more control over the process if you need it.

Thanks Jim, that's the way I thought I'd have to go...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top