Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / February 2007

Tip: Looking for answers? Try searching our database.

Is FIle Open

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary''s Student - 14 Feb 2007 13:58 GMT
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?
Signature

Gary's Student
gsnu200706

Bob Phillips - 14 Feb 2007 14:05 GMT
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

Signature

HTH

Bob Phillips

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

> 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 - 14 Feb 2007 14:35 GMT
Thank you
Signature

Gary's Student
gsnu200705

> Function IsFileOpen(FileName As String)
> Dim iFilenum As Long
[quoted text clipped - 23 lines]
> > 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?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.