OK, I am slowly trying to get the hang of things. At the bottom is what I
have come with as something I can call from Word VBA. When I build it I get
two files one dll and other tlb. Can I just add these to references in Word
and start using or do I need to do something else before that?
Thanks
Regards
Imports System
Imports System.Reflection
Imports System.Runtime.InteropServices
<Assembly: AssemblyKeyFile("C:\Events
Manager\Contacts\EventHelper\EventHelper\EventHelp er.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
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:et**************@tk2msftngp13.phx.gbl...
* "John" <jo**@nospam.infovis.co.uk> scripsit: How can I expose procedures (function or sub) in my vb.net app to vba in
word?
Please do not make excessive use of X-posts.
You can make classes and methods visible to COM and use the DLL within
your VBA application. You will find a sample for using a .NET DLL from
within VB6 here:
<http://www.mvps.org/dotnet/dotnet/sa...nloads/MyComLi
b.zip>
--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>