Function IsMsOfficeRunning() As
IsMsOfficeRunning (Byval Filename As String) As Integer
This function makes some API calls to check if an MS Office Word or Excel application is running with the passed Filename in use. If this is the case the function returns True, otherwise False.
Name of the file to be checked whether it is in use by any MS Office Word or Excel task.
Fnam = “c:\MyDocument.doc”
If IsMsOfficeRunning(fnam) Then
Call MessageDialog(“The file “ & fnam & “ is in use”,0, _
”Microsoft Word/Excel is running”)