Parameters to open a specifice worksheet within a workbook from a command line.


Posted by Wayne Sharp on January 25, 2002 9:13 AM

This has got to be simple as dirt but I haven't found anyone that can give me the command line parameters to open a specific worksheet within a workbook.

Example: Workbook One has sheets one, two, three, four. I want a link on my desktop to go directly to sheet three within workbook one. Also a link to go to sheet four, etc.

I tried to create a command line parameter to open a workbook then run a macro that went to a specific sheet but didn't do something right. As far I know only one auto open macro is allowed, so that won't work to open different worksheets.

Thank you for any help given.

Posted by NiuN on January 25, 2002 9:23 AM


in this example let say u 1 2 open sheet3 everytime u open
your wb :

sub auto_open()
sheets("sheet3").select
end sub

hth

Posted by Joe Was on January 25, 2002 1:10 PM

Build a navagation workbook. Put form buttons on the sheet. When you press a button the code opens and selects the sheet of interest. Like a menu. you can also build short macros which open a workbook, Like:

Workbooks.Open "myList.xls"
ActiveWorkbook.RunAutoMacros xlAutoOpen

and

within the workbook add:

Private Sub Workbook_Open()
Worksheets("X").Select
End Sub

You can nest workbooks on open with a set of:

Workbooks("XXX.xls").Activate

statements.

If you want to select from another application, like "Word" you can:

Set xl = CreateObject("Excel.Sheet")
xl.Application.Workbooks.Open "XXX.xls"

If Excel is not loaded you can load it with,

' You can also use the return value of the Shell function.
ReturnValue = Shell("c:\EXCEL\EXCEL.exe",1) ' Run the Microsoft Excel application.
AppActivate ReturnValue ' Activate Microsoft
' Excel.

If you want to start multiple incidences of Excel, use:

Application.ActivateMicrosoftApp xlMicrosoftExcel

If you are not running Windows2000 or NT you can call batch files with the "Shell" function. Which may also offer some options at startup?

Dim RetVal
RetVal = Shell("C:\BATS\myBat.bat", 1)

What you asked for can be done, you just need to decide how you what to do it, sa command line options are limited, you may need another system, one based upon the ideas above. As a side note you could use "C" or regular "VB" to write a interface, but a worksheet menu system will work just the sane. JSW

Posted by Sergey on March 28, 2002 8:03 PM

: This has got to be simple as dirt but I haven't found anyone that can give me the command line parameters to open a specific worksheet within a workbook.



Posted by Sergey on March 28, 2002 8:10 PM

It don't work another applications", such as msWord. I don't understand where you find property
xlMicrosoftExcel !!!!!
I need to connect to active document ms Excel from Delphy application.