Process flow

VBA opens multiple files for processing.

Executable file (with VBA)
A.xls file
B.xls file
C.xls file

And, due to circumstances, only the A.xls file is closed during processing to free up memory.

However, for example, if there is a problem in the middle of processing, the error processing is skipped.

Current situation

Even if there is a problem during the process and the error process is skipped,
The code that closes all files and frees memory at the end of processing.

However, for example, if you have trouble closing the A.xls file and skipping error processing
An error occurs in the code that closes the A.xls file and releases the memory.

Specific error location
'Close A.xls file (A.xls = SendFile)
       'There is a closing process in the middle of the process.
       SendFile.Close SaveChanges: = True

'Processing when an error occurs
'Close A.xls file
    If SendFile.Name<>"" Then
        SendFile.Close SaveChanges: = True
    End If
    'Error message
    MsgBox "Error in processing Capability Building ("&strError&")"&_
        vbCrLf&"Error Number:"&Err.Number&_
        vbCrLf&"Error description:"&Err.Description
End Sub

The above part closes the A.xls file in the middle of processing.
If an error occurs after that,

'Close A.xls file
    If SendFile.Name<>"" Then
        SendFile.Close SaveChanges: = True
    End If

An error occurs in this part.
It seems that A.xls (= SendFile.Name) has already been closed.


In this case

① Determine if the file is open
② Close if open

I think it would be good to judge

, but I can't find that code.

Is there code that determines if a file is open?