Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to check Excel file already Open
Anybody know the command to check Excel file already Open by somebody else
with VBA ? thx |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error Handling - Check a file isn't already open before overwritin | Excel Discussion (Misc queries) | |||
How to check for Open File! | Excel Discussion (Misc queries) | |||
check if file is already open | Excel Discussion (Misc queries) | |||
Check file open status | Excel Programming | |||
check if a file exists / is open | Excel Programming |