open another excel file

P

Patrick Barao

I am trying to add a button on a excel file where it will allow me to open
another excel file. Can this be done with templates or by using formulas?

Patrick
 
F

Frank Kabel

Hi Patrick
for this you need VBA (not possible with formulas). e.g. assign
something like the following to a button

sub foo()
dim old_wbk as workbook
dim new_wbk as workbook
application.screenupdating=false
set old_wbk = activeworkbook
workbooks.open "C:\temp\newfile.xls"
set new_wbk = activeworkbook
old_wbk.activate
application.screenupdating=true
end sub
 
D

Don Guillett

Here is one I use from a double click event. Right click sheet tab>view
code>copy/paste this>SAVE
Now, all you have to do is double click on a cell with typed in workbook
name such as: myworkbook

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If ActiveCell.Value = "" Then Exit Sub
workbookname = ActiveCell.Value
On Error GoTo OpenWorkbook
Windows(workbookname & ".xls").Activate
Exit Sub
OpenWorkbook:
Workbooks.Open(workbookname & ".xls").RunAutoMacros xlAutoOpen
End Sub
 
N

Nimit Mehta

Instead of using VB, use hyperlink and path it to your
workbook that you want to open. Press CTRL + K for adding
a hyperlink. Browse. Then in "text to display" type
something like OPEN.
-Nimit
 
Top