Function IsOpen(sFile As String) As Boolean
IsOpen=False
Dim fFile As Integer
fFile = FreeFile()
On Error GoTo ErrOpen
Open sFile For Binary Lock Read Write As fFile
Close fFile
Exit Function
ErrOpen:
If Err.Number = 70 Then
IsOpen = True
End If
End Function
'调用:
Private Sub Command1_Click()
If IsOpen("C:\test.mdb") Then MsgBox "文件已经打开!"
End Sub