Macro to open another workbook

K

Kevlar

The following macro opens another workbook and makes it active.

Workbooks.Open Filename:= _
"C:\Program Files\Estimating\Shipment Requisition Form.xls"
Windows("Estimating.xls").Activate

What should I add to check if it is already open, and if so, just mak
it active. i.e do not try to reopen it.

Thank
 
D

Don Guillett

This is one I use from a double click event to open/activate from a typed
name in a cell.
Sub GetWorkbook()
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
 
B

Bob Phillips

Dom oWb as Workbook

On Error Resume Next
Set oWb = Workbooks.Open("Shipment Requisition Form.xls")
On Error Goto 0
If oWb Is Nothing Then
Workbooks.Open Filename:= _
"C:\Program Files\Estimating\Shipment Requisition Form.xls"
Windows("Estimating.xls").Activate
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top