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....
 
Hi Ian,

Several ways. Here is a routine posted by John Green:

Sub IsWorkBookOpenDemo()
If IsWorkBookOpen("a.xls") = False Then Workbooks.Open "C:\a.xls"
If IsWorkBookOpen("b.xls") = False Then Workbooks.Open "C:\b.xls"
If IsWorkBookOpen("c.xls") = False Then Workbooks.Open "C:\c.xls"
End Sub
 
You need the function also

Function IsWorkBookOpen(sWB)
On Error GoTo NotOpen
Workbooks(sWB).Activate
IsWorkBookOpen = True
Exit Function
NotOpen:
IsWorkBookOpen = False
End Function
 
I have tried this but I get the message back that the workbook isn'
open when it is on another network PC!
 

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