Is workbook open?

  • Thread starter Thread starter ianripping
  • Start date Start date
I

ianripping

Is there some simple code for :

If workbook E:\temp.xls is already open by another user the
msgbox("Open Already") else _ continue....
 
Here is one I use from a menu with the filename typed into a cell. If open,
it activates. If not, it opens.
The key here is to use the on error.

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
 

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