Hi Alex,
Ah, yes, interesting...
You would need to put code directly into the document's project (or its template's).
A callback isn't something I've gotten around to using, myself, but here's an
example of what is meant, from a beta group I was in:
<<Here's an example for you that illustrates with the OnKey...
1. Create a new workbook and put the following code in a module:
Dim managedObject As Object
Public Sub RegisterCallback(callback As Object)
Set managedObject = callback
Application.OnKey "^m", "DoManagedCallBack"
End Sub
Public Sub DoManagedCallBack()
managedObject.HandleCtrlM
End Sub
2. Then, create a new Excel project based on the existing workbook you
created.
3. Add the following code to the project:
Private Sub ThisWorkbook_Open() Handles ThisWorkbook.Open
ThisApplication.Run("RegisterCallback", Me)
End Sub
Public Sub HandleCtrlM()
MsgBox("HandleCtrlM")
End Sub
4. Press F5 to run; when you press Ctrl+m in Excel, the DoManagedCallBack
routine in the assembly is run.
So, what's happening here is that a) you call a macro in the workbook to
pass it a reference to the assembly's class, b) the macro stores the
reference to the object, c) you set up OnKey to call a macro in the
workbook, and d) when the "OnKey" routine fires, it will use the stored
reference to the object to call a public method (HandleCtrlM in this
example) in the assembly code. Of course, for this to work, the VBA
security settings must allow the VBA code in the workbook to run.>>
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply in
the newsgroup and not by e-mail