I've written a function below to check if a file is allready open or not.
Function IsWorkBookOpen(FileName As String) As Boolean
Dim ff As Long
ErrNo As Long
ff = FreeFile()
On Error Resume Next
Open FileName For Input Lock Read As #ff
ErrNo = Err
On Error GoTo 0
If Err.Number = 0 Then
IsWorkBookOpen = False
ElseIf Err.Number = 70 Then
IsWorkBookOpen = True
If it's open I get error number 70 if it's not I get error 0.
When I run the code and I get to [Open FileName For Input Lock Read As #ff] VBA stops the macro to tell me I have error number 70.
What am I doing wrong?
check in VBA editor window -> Tools -> Options -> General -> Error Trapping
Should be : Break on Unhadled Errors
Retrieving data ...