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 derfloh 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
Joined
Oct 2, 2002
Messages
6
Location
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
 
thanks, i am gonna try that!

Thomas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top