View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Rudy S Rudy S is offline
external usenet poster
 
Posts: 2
Default How to check Excel file already Open

Thx Bob, it works so good.

"Bob Phillips" wrote in message
...
Here is a tried method

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

RP
(remove nothere from the email address if mailing direct)


"Rudy S" wrote in message
...
Anybody know the command to check Excel file already Open by somebody
else
with VBA ?

thx