Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Is FIle Open

2 views
Skip to first unread message

Bob Phillips

unread,
Feb 14, 2007, 9:05:46 AM2/14/07
to

Function IsFileOpen(FileName As String)
Dim iFilenum As Long
Dim iErr As Long

On Error Resume Next
iFilenum = FreeFile()
Open FileName For Input Lock Read As #iFilenum
Close iFilenum
iErr = Err
On Error GoTo 0

Select Case iErr
Case 0: IsFileOpen = False
Case 70: IsFileOpen = True
Case Else: Error iErr
End Select

End Function

Sub test()
If Not IsFileOpen("C:\MyTest\volker2.xls") Then
Workbooks.Open "C:\MyTest\volker2.xls"
End If
End Sub


--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Gary''s Student" <GarysS...@discussions.microsoft.com> wrote in message
news:C223D7AA-1A58-4B0E...@microsoft.com...
> We have a .xls file on a server. Is there any way to determine if another
> user has the file open before trying to open it myself?
> --
> Gary's Student
> gsnu200706


Gary''s Student

unread,
Feb 14, 2007, 9:35:30 AM2/14/07
to
Thank you
--
Gary's Student
gsnu200705
0 new messages