How to Detect when third part application releases my WorkBook
One thing you could do is run a function in a loop that checks if the file
is still
open:
Function FileIsOpen(strFile As String) As Boolean
Dim hFile As Long
On Error GoTo OpenError
hFile = FreeFile
Open strFile For Input Lock Read As #hFile
Close #hFile
Exit Function
OpenError:
FileIsOpen = Err.Number = 70
End Function
So you could run code like this:
'waiting loop that will keep running while file is open
Do While FileIsOpen("C:\Test.xls")
Loop
'now run your own code here
If that third party app has an API that you can access then there might be a
more efficient way.
RBS
"Aldo" wrote in message
...
Hi there!
We have an application that export data to an MS Excel Workbook.
The workbook is based on a template I created.
When that application finish exporting the data, it pop ups a message and
releases the workbook.
What I need is to find a way (event or other way) to detect the moment
that
the third part application releases the workbook, then activating a macro
of
my self.
Thanks in advance for any help!
Aldo.
|