아래 기능을 사용하여 파일이 다른 프로세스에서 사용 중인지 확인할 수 있습니다.

파일에 대한 전체 액세스 권한을 얻을 수없는 경우 함수는 True를 반환합니다.

Function FileAlreadyOpen(FullFileName As String) As Boolean

' returns True if FullFileName is currently in use by another process

' example: If FileAlreadyOpen("C:\FolderName\FileName.xls") Then...

Dim f As Integer

f = FreeFile

On Error Resume Next

Open FullFileName For Binary Access Read Write Lock Read Write As #f

Close #f

' If an error occurs, the document is currently open.

If Err.Number <> 0 Then

FileAlreadyOpen = True

Err.Clear

'MsgBox "Error #" & Str(Err.Number) & " - " & Err.Description

Else

FileAlreadyOpen = False

End If

On Error GoTo 0

End Function