Open file pop-up (network)

G

Guest

Hello,

The company I work for has a network and when a shared file is open, I
ususally get a pop-up box that asks if I want to open the file as read only,
wait for notificatin that the file is OK to open or cancel. I have written
some code (see attached) and I don't get this box pop-up box letting me know
that the file is already open and this creates file integrity problems if the
file is already open by another user.

I think I want the pop-up box, and I am open to other suggestions. Any
ideas how to write the code?

IsOpen = False
For Each wb In Workbooks 'check thru all open workbooks
If wb.Name = "Master Log.xls" Then 'change to your file's name
IsOpen = True 'your file is already
End If
Next wb
If IsOpen = False Then
Workbooks.Open Filename:="\\Tuc-nas\Master Log\Master Log.xls"
'This opens the other workbook if it was
closed
End If


Thanks,
Cameron
 
T

Tom Ogilvy

That only checks if the file is open in the same instance of excel.
Perhaps the more general


http://support.microsoft.com?kbid=138621
XL: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=291295
XL2002: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=213383
XL2000: Macro Code to Check Whether a File Is Already Open

http://support.microsoft.com?kbid=184982
WD97: VBA Function to Check If File or Document Is Open


is what you want.
 

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

Top