Context: |
Function |
Library/Class: |
Utilities |
Function FileInUse() As
FileInUse (Filename As String) As Integer
This function checks if a particular file located in the file system is in use. It first calls the function IsMsOfficeRunning(Filename) which in turn makes some API calls looking for any MS Word or Excel task that may have the specified file in use (see IsMsOfficeRunning). If the file is in use by MS Office, the FileInUse function returns True at this point. Otherwise it will perform a low-level exclusive file access. If successful the file is not in use by any application and FileInUse returns False, otherwise True.
There are situation where MS Office temporarily closes a file that it has in use and therefore a pure low-level file access check might cause unpredictable results. That is why this function checks first for existing MS Office tasks and communicates with the task whether it has a particular file in use or not. This effect is to keep in mind when using this function on other filetypes used by different applications then MS Office, as in such case only the low-level file access will determine the FileInUse’s result.
Parameters:
Name of the file including its path.
Return Value:
|