- excel vba check if workbook is open
- isfileopen vba
- excel vba check if workbook is open by another user
- vba check if workbook is open and if not open it
- isworkbookopen vba
- excel vba check if workbook open then close
Function IsFileOpen(filename As String)Where:
Dim filenum As Integer, errnum As Integer
On Error Resume Next
filenum = FreeFile()
Open filename For Input Lock Read As #filenum
Close filenum
errnum = Err
On Error GoTo 0
Select Case errnum
Case 0
IsFileOpen = False
Case 70
IsFileOpen = True
Case Else
End Select
End Function
If Not IsFileOpen("FileDirectoryToOpen") Then
Workbooks.Open "FileDirectoryToOpen"
End If
FileDirectoryToOpen = complete path if your file name. The file must consist of file extension. Example: For Excel, must ended with .XLSX
No comments:
Post a Comment