Hi =?Utf-8?B?TmVtZXNpc3Q=?=,
I don´t see what do you mean hier by "callback".
Could you give me some more hints about this?
This is not something I've tried, personally, but here's an
example I picked up a while back. The principle would work
the same in Word.
----
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