Hi Sergey,
Yes as we with a COM Add-in can access the calculation event on the
worksheet level. Below is an example how You can set it up in a VB 6.0 COM
Add-in. All code is in the Connection Class:
Option Explicit
'Here I use early binding to Excel.
Private xlApp As Excel.Application
Private xlWBook As Excel.Workbook
'In order to create events on the Worksheet level.
'You can use all the available events if wanted.
Private WithEvents xlWSheet As Excel.Worksheet
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal
ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As
Object, custom() As Variant)
Set xlApp = Application
Set xlWBook = xlApp.Workbooks.Open("c:\test.xls")
Set xlWSheet = xlWBook.Worksheets(2)
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
'Cleaning up.
Set xlWSheet = Nothing
Set xlWBook = Nothing
Set xlApp = Nothing
End Sub
Private Sub AddinInstance_OnAddInsUpdate(custom() As Variant)
'No code here.
End Sub
Private Sub AddinInstance_OnBeginShutdown(custom() As Variant)
'No code here
End Sub
Private Sub AddinInstance_OnStartupComplete(custom() As Variant)
'No code here.
End Sub
Private Sub xlWSheet_Calculate()
'Whenever the sheet is being recalculated this event kicks in.
MsgBox "I watch the calculation of the worksheet: " & xlWSheet.Name
End Sub
If You prefer to use a managed COM Add-ins then it shouldn't be a problem to
port the above example.
---------------
With kind regards,
Dennis
Weekly Blog .NET & Excel:
http://xldennis.wordpress.com/
My English site:
http://www.excelkb.com/default.aspx
My Swedish site:
http://www.xldennis.com/