![]() |
How to check Excel file already Open
Anybody know the command to check Excel file already Open by somebody else
with VBA ? thx |
How to check Excel file already Open
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 |
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 |
All times are GMT +1. The time now is 08:27 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com