ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a Excel file to a Specified Worksheet (https://www.excelbanter.com/excel-programming/383945-opening-excel-file-specified-worksheet.html)

[email protected]

Opening a Excel file to a Specified Worksheet
 
I'm helping to lay out a simple webpage to allow users easy access to
a few excel workbooks that contain all sorts of interesting things
they might like to look at. Some of the workbooks are pretty
overwhelming, so I'd like to link to the worksheets that contain the
data the general public would find interesting (i.e. charts, and data
summary sheets)

I'd like a way to open a workbook to a worksheet specified in the
command line if possible. I can write a macro that opens a designated
worksheet, but I don't know how to get it to read a command line
argument.

Any help would be greatly appreciated.

Thanks,
Thomas


Jim Jackson

Opening a Excel file to a Specified Worksheet
 
You could either place hyperlinks on the sheet along with text explaining
what to expect when going to each sheet, and hyperlinks on each sheet taking
them back to the original, or you could create some code that would "demo"
the sheets of interest:

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 10 ' (seconds)
waitTime = TimeSerial(newHour, newMinute, newSecond)

Sheets(12).Range("A1").activate
Application.Wait waitTime

Sheets(23).Range("A1").activate
Application.Wait waitTime

You could include activating specific ranges on each sheet with the "wait"
command set for the time you think appropriate and go from there to make the
presentation as complex as you wish.

--
Best wishes,

Jim


" wrote:

I'm helping to lay out a simple webpage to allow users easy access to
a few excel workbooks that contain all sorts of interesting things
they might like to look at. Some of the workbooks are pretty
overwhelming, so I'd like to link to the worksheets that contain the
data the general public would find interesting (i.e. charts, and data
summary sheets)

I'd like a way to open a workbook to a worksheet specified in the
command line if possible. I can write a macro that opens a designated
worksheet, but I don't know how to get it to read a command line
argument.

Any help would be greatly appreciated.

Thanks,
Thomas



Chip Pearson

Opening a Excel file to a Specified Worksheet
 
You could write the link something like

Click <a href="C:\Book1.xls#TheSheet"Here</a to open file.</p

change the path of the workbook name to file name, either local or on a
network share.

Or you can use VBA code in the ThisWorkbook code module of the target file
such as

Private Sub Workbook_Open()
Me.Worksheets("TheSheet").Select
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

wrote in message
oups.com...
I'm helping to lay out a simple webpage to allow users easy access to
a few excel workbooks that contain all sorts of interesting things
they might like to look at. Some of the workbooks are pretty
overwhelming, so I'd like to link to the worksheets that contain the
data the general public would find interesting (i.e. charts, and data
summary sheets)

I'd like a way to open a workbook to a worksheet specified in the
command line if possible. I can write a macro that opens a designated
worksheet, but I don't know how to get it to read a command line
argument.

Any help would be greatly appreciated.

Thanks,
Thomas




[email protected]

Opening a Excel file to a Specified Worksheet
 
After digging through some more posts, it seems like there is no easy
way to pass any sort of command line option into excel. (If there is
please let me know!)

As an alternative I did find a reference to a script that could open
the file and then run a macro <a href = "http://groups.google.com/
group/microsoft.public.excel.programming/browse_thread/thread/
a500b205bb204bd0/f38f7c0a98d20084?lnk=gst&q=reading+from+the+comman d
+line&rnum=29#f38f7c0a98d20084"here</a

Dim objxl, xlwbk
Set objxl = CreateObject("Excel.Application")
objxl.Visible = True
Set xlwbk = objxl.Workbooks.Open("mybook.xls")
objxl.Run ("OpenMySheet")

So I can write a couple different scripts (or better yet, write one
script that accepts command line arguments) like this for the various
worksheets I'd like to open to and then link to the script(s) instead
of the .



All times are GMT +1. The time now is 06:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com