Shortcut

D

Drew

Can I set up a desktop shortcut that will open a specific
worksheet within an Excel workbook?
 
M

Mike A

Can I set up a desktop shortcut that will open a specific
worksheet within an Excel workbook?

I don't think you can pass a sheet name as a parameter to Excel, but
you could write a macro that will select a sheet automatically when
the file is opened.

In 'ThisWorkbook' code:

Private Sub Workbook_Open()

Sheet1.Activate

End Sub

(This example uses the programmatic name of the sheet from the project
explorer window in the VBE - it will work regardless of the sheet's
name.)


OR...


Private Sub Workbook_Open()

Sheets("MyData").Activate

End Sub

(This example uses the visible (tab) name of the sheet. If a user
changes the sheet name, the code may produce an error.)



Mike Argy
Custom Office Solutions
and Windows/UNIX applications

Please post on-topic responses to the newsgroup

To e-mail me, remove nospam from the address in the headers
 
J

Jim Rech

You can do what you want from a VBS script. Create a text file on your
desktop with a name like OpenMySheet.VBS with contents like this:

Dim XL
Set XL = CreateObject("Excel.Application")
Set WB = XL.Workbooks.Open("c:\Book1.xls")
WB.Worksheets("MySheet").Activate
XL.Visible = True
 
M

Mike A

You can do what you want from a VBS script. Create a text file on your
desktop with a name like OpenMySheet.VBS with contents like this:

Dim XL
Set XL = CreateObject("Excel.Application")
Set WB = XL.Workbooks.Open("c:\Book1.xls")
WB.Worksheets("MySheet").Activate
XL.Visible = True


That's an excellent solution!

....Didn't one of Microsoft's security 'fixes' disable VBS? Or was it
WSH? I can't keep track of their kite string and bubble gum fixes
anymore...


Mike Argy
Custom Office Solutions
and Windows/UNIX applications

Please post on-topic responses to the newsgroup

To e-mail me, remove nospam from the address in the headers
 
J

Jim Rech

Didn't one of Microsoft's security 'fixes' disable VBS?

Not that I know of but I don't follow "security news" all that closely. But
if scripting were disabled why not disable all executables? Oh wait, then
computers wouldn't do anything. I guess we have to trust something.

--
Jim Rech
Excel MVP
| On Thu, 8 Jul 2004 07:14:21 -0400, "Jim Rech" <[email protected]>
| wrote:
|
| >You can do what you want from a VBS script. Create a text file on your
| >desktop with a name like OpenMySheet.VBS with contents like this:
| >
| >Dim XL
| >Set XL = CreateObject("Excel.Application")
| >Set WB = XL.Workbooks.Open("c:\Book1.xls")
| >WB.Worksheets("MySheet").Activate
| >XL.Visible = True
|
|
| That's an excellent solution!
|
| ...Didn't one of Microsoft's security 'fixes' disable VBS? Or was it
| WSH? I can't keep track of their kite string and bubble gum fixes
| anymore...
|
|
| Mike Argy
| Custom Office Solutions
| and Windows/UNIX applications
|
| Please post on-topic responses to the newsgroup
|
| To e-mail me, remove nospam from the address in the headers
 
D

Dave Peterson

I think at one time, there were lots of viruses/worms/bad things that were being
sent via .VBS files.

A lot of people turned of scripting because of that. (I did for a day or two.)

Maybe that's what you're remembering???????
 
M

Mike A

I think at one time, there were lots of viruses/worms/bad things that were being
sent via .VBS files.

A lot of people turned of scripting because of that. (I did for a day or two.)

Maybe that's what you're remembering???????

Yes, that's it! Everywhere you looked, 'Uninstall WSH!' or 'Delete
..vbs files from your file types!' was the only advice around.

I think it may have been during the LoveBug/Melissa timeframe. I also
remember that it was pointless advice, at least on Win98. You could
uninstall WSH and the .vbs scripts still ran. Apparently the only
thing that uninstalling removed was the check mark in the list of
components!

Anyway, I am going to do some research on creating .vbs scripts like
the one Jim used here. I have been using things like the start
command in .bat or .cmd files to create specialized shortcuts, but VBS
really lets you do a lot more!

Thanks!



Mike Argy
Custom Office Solutions
and Windows/UNIX applications

Please post on-topic responses to the newsgroup

To e-mail me, remove nospam from the address in the headers
 

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