Is workbook open on the network?

I

ianripping

I have a LAN network. I want a command that says if the workbook i
open on another PC by another user then msgbox("Already open") els
open it as normal.

Any ideas
 
A

Andy Wiggins

It's already part of the kit Uncle Bill supplies. If the workbook isn't open
elsewhere it will open as normal. If someone else has it open a warning
dialog will open allowing the user to open it as read-only, be notified when
it's available or not to open it.

--
Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"
 
I

ianripping

Yes, but instead of that message appearing, I want it to just not ope
then workbook
 
M

Michel Pierron

Hi ianripping,
You can use:
Private Sub Workbook_Open()
If ThisWorkbook.ReadOnly Then ThisWorkbook.Close False
End Sub

MP
 
B

Bob Phillips

Ian,

This function will test it, but it does open it to find out

Function IsNetworkOpen(filename As String)
Dim nFile As Long

IsNetworkOpen = False

nFile = FreeFile()
On Error Resume Next
Open filename For Input Lock Read Write As #nFile
If Err <> 0 Then
If Err.Number = 70 Then
IsNetworkOpen = True
Else
IsNetworkOpen = "No such file"
End If
End If
On Error GoTo 0
Close #nFile

End Function



--

HTH

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

ianripping

Michell I got yours to work.

Is there any way of reporting the network pc where the file is open
 
Top