Macro to open another workbook

  • Thread starter Thread starter Kevlar
  • Start date Start date
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
 
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
 
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)
 

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

Back
Top