Calling COMAddin functions from another app

P

Peter Karlström

Hi

I'm developing a COM-Addin for Word to replace old template macros.
This is done in VB6.

In this project it is necessary to call functions in the COMAddin from the
same application which have started Word in the first place.

To test this I have tried to create another VB6 application which starts Word
and connects to the COMAddin in question.
Everything works fine this far.
But there seems to be no way of calling a Public Sub in the COM Addin from
the other VB6 application.

What am I doing wrong here?

Thanks in advance for any help
 
K

Ken Slovak - [MVP - Outlook]

Create public subs in your Designer class or public Connect class if not
using a designer. In OnConnection you need to set the AddInInst passed to
you as follows:

AddInInst.Object = Me

Then you can call the public subs in your class, and you can do the same
with functions and properties.

You access the subs as follows:

Dim oAddin As Office.COMAddIn
Dim AddinBase As Object

Set oAddin = oOutlook.COMAddIns.Item("MyAddin.Connect")
Set AddinBase = oAddin.Object

Call AddinBase.MySub(whatever)
 
P

Peter Karlström

Hi Ken

This was exactly what I needed.

Thanks a million

Regards
--
Peter Karlström
Midrange AB
Sweden


Ken Slovak - said:
Create public subs in your Designer class or public Connect class if not
using a designer. In OnConnection you need to set the AddInInst passed to
you as follows:

AddInInst.Object = Me

Then you can call the public subs in your class, and you can do the same
with functions and properties.

You access the subs as follows:

Dim oAddin As Office.COMAddIn
Dim AddinBase As Object

Set oAddin = oOutlook.COMAddIns.Item("MyAddin.Connect")
Set AddinBase = oAddin.Object

Call AddinBase.MySub(whatever)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top