Here is some of my code in word;
Public Caller As EventHelper.EventHelper
Public Sub SetCaller(ByRef x As EventHelper.EventHelper)
Caller = x
End Sub
I would ideally like the caller variable to have the class reference
assigned so I can call the vb.bet com class from word using the reference,
as follows;
Call ActiveDocument.Caller.RaiseWordDocSaved(ActiveDocument)
The word (and vb.net app) knows about the EventHelper.EventHelper class as
it is a com class and is referenced by both word and vb.net. Basically I am
using the class to make word communicate with vb.net app. The code for the
com class is given at the end below. If there is an easier way for word vba
to call a procedure in my vb.net app then I would like to know.
Thanks
Regards
' File:EventHelper.vb
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
<Assembly: AssemblyKeyFile("C:\EventHelper.snk")>
Namespace MyCompany.EventHelper
Public Interface IEventHelper
Event WordDocSaved(ByRef Doc As Object)
Event WordDocPrinted(ByRef Doc As Object)
Function Instance() As IEventHelper
Sub RaiseWordDocSaved(ByRef Doc As Object)
Sub RaiseWordDocPrinted(ByRef Doc As Object)
End Interface
<ClassInterface(ClassInterfaceType.None)> _
Public Class EventHelper
Implements IEventHelper
Public Event WordDocSaved(ByRef Doc As Object) Implements
IEventHelper.WordDocSaved
Public Event WordDocPrinted(ByRef Doc As Object) Implements
IEventHelper.WordDocPrinted
Private Shared _Instance As EventHelper
Public Function Instance() As IEventHelper Implements IEventHelper.Instance
If (_Instance Is Nothing) Then
SyncLock GetType(EventHelper)
If (_Instance Is Nothing) Then
_Instance = New EventHelper
End If
End SyncLock
End If
Return _Instance
End Function
Public Sub RaiseWordDocSaved(ByRef Doc As Object) Implements
IEventHelper.RaiseWordDocSaved
RaiseEvent WordDocSaved(Doc)
End Sub
Public Sub RaiseWordDocPrinted(ByRef Doc As Object) Implements
IEventHelper.RaiseWordDocPrinted
RaiseEvent WordDocPrinted(Doc)
End Sub
End Class
End Namespace
[quoted text, click to view] "Armin Zingler" <az.nospam@freenet.de> wrote in message
news:ON6yrlYzDHA.2568@TK2MSFTNGP09.phx.gbl...
> "John" <john@nospam.infovis.co.uk> schrieb
> > All I need at this point is to pass a reference to a COM library
> > class to word. I am doing this from vb.net which has the reference to
> > this COM class.
>
> To which Word object or method do you want to pass the object?
>
>
> --
> Armin
>
>
http://www.plig.net/nnq/nquote.html >
http://www.netmeister.org/news/learn2quote.html >