Hi Rob,
There is also an OnRecalc event in the C API. Below I paste an add-in
that shows how it can be used.
I'm not sure it's easier or better than the COM event, but one
advantage is that you wouldn't need the interop assembly. (I remember
you asked about xlcOnKey before.)
I haven't quite figured out how to handle COM events late-bound (it is
possible, but needs some connection point set-up).
Cheers,
Govert
<DnaLibrary Name="Test OnRecalc" Language="VB">
<Reference Path="System.Windows.Forms.dll" />
<![CDATA[
Imports System.Windows.Forms
Public Module Test
Public Sub ShowRecalc()
MessageBox.Show("Recalculating...", "Test OnRecalc")
End Sub
Public Sub ShowRecalcSheet()
MessageBox.Show("Recalculating a sheet ...", "Test OnRecalc")
End Sub
<ExcelCommand(MenuText:="Install OnRecalc Handler")> _
Public Sub InstallOnRecalc()
XlCall.Excel(XlCall.xlcOnRecalc, Nothing, "ShowRecalc")
MessageBox.Show("OnRecalc handler installed.", "Test
OnRecalc")
End Sub
<ExcelCommand(MenuText:="Uninstall OnRecalc Handler")> _
Public Sub UninstallOnRecalc()
XlCall.Excel(XlCall.xlcOnRecalc, Nothing, Nothing)
MessageBox.Show("OnRecalc handler uninstalled.", "Test
OnRecalc")
End Sub
<ExcelCommand(MenuText:="Install OnRecalc Handler for Single
Worksheet")> _
Public Sub InstallOnRecalcForSheet()
Dim SheetName As String
Dim InputType_Text As Integer = 2
SheetName = XlCall.Excel(XlCall.xlfInput, "Which sheet should
be watched? " & vbCrLf & "(In the format [Book1.xls]Sheet2)",
InputType_Text, "Test OnRecalc")
' TODO: Check the SheetName is valid
XlCall.Excel(XlCall.xlcOnRecalc, SheetName, "ShowRecalcSheet")
MessageBox.Show("OnRecalc handler installed.", "Test
OnRecalc")
End Sub
<ExcelCommand(MenuText:="Uninstall OnRecalc Handler for Single
Worksheet")> _
Public Sub UninstallOnRecalcForSheet()
Dim SheetName As String
Dim InputType_Text As Integer = 2
SheetName = XlCall.Excel(XlCall.xlfInput, "Which sheet should
be cleared? " & vbCrLf & "(In the format [Book1.xls]Sheet2)",
InputType_Text, "Test OnRecalc")
XlCall.Excel(XlCall.xlcOnRecalc, SheetName, Nothing)
MessageBox.Show("OnRecalc handler uninstalled.", "Test
OnRecalc")
End Sub
End Module
]]>
</DnaLibrary>
> >
exceldna+u...@googlegroups.com<exceldna%2Bunsubscribe@googlegroups.c om>
> > .