ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   CommandButton to open a Excel workbook (https://www.excelbanter.com/excel-discussion-misc-queries/225285-commandbutton-open-excel-workbook.html)

aussiegirlone

CommandButton to open a Excel workbook
 
I have a command button that when clicked goes to another Worksheet. Can this
command button code be edited to goto another WorkBook instead?

Private Sub CommandButton1_Click()
Worksheets("HoursWorked").Select
Application.Goto Worksheets("HoursWorked").Range("A1"), Scroll:=True 'or
false??
End Sub

Gary''s Student

CommandButton to open a Excel workbook
 
Try something like:

Sub Button1_Click()
ActiveWorkbook.FollowHyperlink Address:="file:///C:\test\gamma.xls"
Sheets("Sheet2").Activate
End Sub

Using the hyperlink will take you to the workboook if it already open.
Otherwise, it will open the workkbook, activate it and allow you to activate
any sheet within the workbook
--
Gary''s Student - gsnu200840


"aussiegirlone" wrote:

I have a command button that when clicked goes to another Worksheet. Can this
command button code be edited to goto another WorkBook instead?

Private Sub CommandButton1_Click()
Worksheets("HoursWorked").Select
Application.Goto Worksheets("HoursWorked").Range("A1"), Scroll:=True 'or
false??
End Sub


aussiegirlone

CommandButton to open a Excel workbook
 
Sorry to have to say The code you provided is not working. I think you have
misunderstood my question. The commandbutton is in the workbook that I am
using, the code you gave closes this workbook and then reopens it... but that
is not what i want. I want the command button to open another/different
workbook altogether, where I keep references and reports.

"Gary''s Student" wrote:

Try something like:

Sub Button1_Click()
ActiveWorkbook.FollowHyperlink Address:="file:///C:\test\gamma.xls"
Sheets("Sheet2").Activate
End Sub

Using the hyperlink will take you to the workboook if it already open.
Otherwise, it will open the workkbook, activate it and allow you to activate
any sheet within the workbook
--
Gary''s Student - gsnu200840


"aussiegirlone" wrote:

I have a command button that when clicked goes to another Worksheet. Can this
command button code be edited to goto another WorkBook instead?

Private Sub CommandButton1_Click()
Worksheets("HoursWorked").Select
Application.Goto Worksheets("HoursWorked").Range("A1"), Scroll:=True 'or
false??
End Sub



All times are GMT +1. The time now is 05:25 AM.

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