Solved

Locked files

Posted on 1998-07-29
1
198 Views
Last Modified: 2010-05-03
Is there a way to detect if a file is locked (in use)
0
Comment
Question by:dgb
1 Comment
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1467194
Function CheckOpenFile(sFile as String) as Boolean

   Dim nFile As Integer

   nFile = FreeFile

   on error goto Error_Read

   Open sFile For Input Lock Read As #nFile
   Close #nFile

   CheckOpenFile = False

   Exit Function
Error_Read:
   if Err = 70 then
      msgbox "File already open"
   End If

   close #nFile
   
   CheckOpenFile = True

   Exit Function

End Sub
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Macro which automatically sends attachment to Outlook 14 76
Access 2013 combo box not working 3 51
Convert VB6 MSXML2.ServerXMLHTTP process to C# 2 58
TT Auto Dashboard 13 95
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question