Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if a file is opened?

Status
Not open for further replies.

tleducq

Programmer
Oct 2, 2002
6
FI
Hi,

Is there a way to know with VB if a file is opened or not and to control the possibility to open it or not?

Thanks,

Thomas
 
Function IsFileOpen(ByVal tFile As String) As Boolean


On Error GoTo IsOpen

Dim fFile As Integer
fFile = FreeFile()

Open tFile For Input Lock Read Write As fFile
Close fFile



Exit Function


IsOpen:
Resume Leave
Exit Function

Leave:

On Error Resume Next
IsFileOpen = True

End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top