A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Call AddIn-Functions from VBA-Macro



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 21st 08, 11:29 AM posted to microsoft.public.outlook.program_addins
Steffen Grellmann[_2_]
external usenet poster
 
Posts: 9
Default Call AddIn-Functions from VBA-Macro

Hi newsgroup,

is it possible to call public functions of a COM-AddIn (made with VSTO
2005) from outside, especially from a VBA-macro?

Any help would be appreciated.

Kind regards,

Steffen
Ads
  #2  
Old July 21st 08, 03:01 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Call AddIn-Functions from VBA-Macro

Yes, it's possible. For an example download one of the VSTO templates I have
up for Outlook 2007 and look at how I handle setting up calls from the
outside to functions in the COM addin. The same would apply for other
versions of Outlook as well with VSTO.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Steffen Grellmann" wrote in message
...
Hi newsgroup,

is it possible to call public functions of a COM-AddIn (made with VSTO
2005) from outside, especially from a VBA-macro?

Any help would be appreciated.

Kind regards,

Steffen


  #3  
Old July 21st 08, 08:54 PM posted to microsoft.public.outlook.program_addins
Steffen Grellmann[_2_]
external usenet poster
 
Posts: 9
Default Call AddIn-Functions from VBA-Macro

Hi Ken,

thank you very much for replying.

Yes, it's possible. For an example download one of the VSTO templates I have
up for Outlook 2007 and look at how I handle setting up calls from the
outside to functions in the COM addin. The same would apply for other
versions of Outlook as well with VSTO.


But how do I call the CalledFromOutside() from my VBA-Project (which
is a global template in Word with a reference to the Outlook object
library)?

Kind regards,

Steffen
  #4  
Old July 22nd 08, 02:23 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Call AddIn-Functions from VBA-Macro

In the VBA code you'd do something like this, assuming your addin ProgID was
"myAddin":

Dim oAddin As Office.ComAddin
' oOL is an Outlook.Application object

Set oAddin = oOL.COMAddins.Item("myAddin")
If Not (oAddin Is Nothing) Then
If oAddin.Connect = True Then 'if addin running
Dim addinObject As Object
Set addinObject = oAddin.Object
If Not (addinObject Is Nothing) Then
addinObject.CalledFromOutside() ' this is the call
End If
End If
End If

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Steffen Grellmann" wrote in message
...
Hi Ken,

thank you very much for replying.

Yes, it's possible. For an example download one of the VSTO templates I
have
up for Outlook 2007 and look at how I handle setting up calls from the
outside to functions in the COM addin. The same would apply for other
versions of Outlook as well with VSTO.


But how do I call the CalledFromOutside() from my VBA-Project (which
is a global template in Word with a reference to the Outlook object
library)?

Kind regards,

Steffen


  #5  
Old July 23rd 08, 01:43 PM posted to microsoft.public.outlook.program_addins
Steffen Grellmann[_2_]
external usenet poster
 
Posts: 9
Default Call AddIn-Functions from VBA-Macro

Hi Ken,

thank you very much for replying.

Dim oAddin As Office.ComAddin
' oOL is an Outlook.Application object

Set oAddin = oOL.COMAddins.Item("myAddin")
If Not (oAddin Is Nothing) Then
If oAddin.Connect = True Then 'if addin running
Dim addinObject As Object
Set addinObject = oAddin.Object
If Not (addinObject Is Nothing) Then
addinObject.CalledFromOutside() ' this is the call
End If
End If
End If


The oOL.COMAddins.Item supplies me the AddIns stored in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Outlo ok\Addins

and not my VSTO 2007 SE AddIn stored in

HKEY_CURRENT_USER\Software\Microsoft\Office\Outloo k\Addins

How do I access the VSTO AddIn this way?

Kind regards,

Steffen
  #6  
Old July 23rd 08, 02:54 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Call AddIn-Functions from VBA-Macro

That makes no sense at all. It shouldn't matter one way or the other where a
COM addin is registered, in either HKCU or HKLM.

If you look in the registry for your VSTO addin are you matching the
registration name exactly in your code?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Steffen Grellmann" wrote in message
...
Hi Ken,

thank you very much for replying.

Dim oAddin As Office.ComAddin
' oOL is an Outlook.Application object

Set oAddin = oOL.COMAddins.Item("myAddin")
If Not (oAddin Is Nothing) Then
If oAddin.Connect = True Then 'if addin running
Dim addinObject As Object
Set addinObject = oAddin.Object
If Not (addinObject Is Nothing) Then
addinObject.CalledFromOutside() ' this is the call
End If
End If
End If


The oOL.COMAddins.Item supplies me the AddIns stored in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Outlo ok\Addins

and not my VSTO 2007 SE AddIn stored in

HKEY_CURRENT_USER\Software\Microsoft\Office\Outloo k\Addins

How do I access the VSTO AddIn this way?

Kind regards,

Steffen


  #7  
Old July 23rd 08, 09:06 PM posted to microsoft.public.outlook.program_addins
Steffen Grellmann[_2_]
external usenet poster
 
Posts: 9
Default Call AddIn-Functions from VBA-Macro

Sorry, the registry confusion has been my fault. I first had an
underline in the registration name of my AddIn like "Test_2003".
Without that underline oAddin is initiated correctly and the item
collection is returning my AddIn as well as the other ones.

Nevertheless oAddin.Connect is still returning False for me.

Although you commented "'oOL is an Outlook.Application object" I had
to put in the following lines in order to prevent a compilation error
in Words VBA editor:

Dim oOL As Object
Set oOL = outlook.Application

Has this to do with my issue? Developing environment is VSTO SE 2005
and Word 2003/VBA with a reference set to the Outlook object model.


On Wed, 23 Jul 2008 09:54:21 -0400, "Ken Slovak - [MVP - Outlook]"
wrote:

That makes no sense at all. It shouldn't matter one way or the other where a
COM addin is registered, in either HKCU or HKLM.

If you look in the registry for your VSTO addin are you matching the
registration name exactly in your code?

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Steffen Grellmann" wrote in message
.. .
Hi Ken,

thank you very much for replying.

Dim oAddin As Office.ComAddin
' oOL is an Outlook.Application object

Set oAddin = oOL.COMAddins.Item("myAddin")
If Not (oAddin Is Nothing) Then
If oAddin.Connect = True Then 'if addin running
Dim addinObject As Object
Set addinObject = oAddin.Object
If Not (addinObject Is Nothing) Then
addinObject.CalledFromOutside() ' this is the call
End If
End If
End If


The oOL.COMAddins.Item supplies me the AddIns stored in

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Outlo ok\Addins

and not my VSTO 2007 SE AddIn stored in

HKEY_CURRENT_USER\Software\Microsoft\Office\Outloo k\Addins

How do I access the VSTO AddIn this way?

Kind regards,

Steffen

  #8  
Old July 23rd 08, 09:34 PM posted to microsoft.public.outlook.program_addins
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Call AddIn-Functions from VBA-Macro

If Outlook is started "headless" some versions of VSTO won't initialize the
addin. They only initialize the addin when Outlook is started with some UI
such as an Explorer or Inspector. That may have something to do with your
problem.

Another possibility is that since VSTO 2005 SE doesn't fire its Startup()
event until OnStartupComplete() fires in the extensibility interfaces that
you are checking for Connect too early.

I didn't bother writing complete code, just a snippet and indicated that you
need an Outlook.Application object which I called oOL in my code snippet. So
I would expect errors in Word VBA code unless you did instantiate an
Outlook.Application object.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Steffen Grellmann" wrote in message
...
Sorry, the registry confusion has been my fault. I first had an
underline in the registration name of my AddIn like "Test_2003".
Without that underline oAddin is initiated correctly and the item
collection is returning my AddIn as well as the other ones.

Nevertheless oAddin.Connect is still returning False for me.

Although you commented "'oOL is an Outlook.Application object" I had
to put in the following lines in order to prevent a compilation error
in Words VBA editor:

Dim oOL As Object
Set oOL = outlook.Application

Has this to do with my issue? Developing environment is VSTO SE 2005
and Word 2003/VBA with a reference set to the Outlook object model.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call CALLBACK functions from COM Add-In K.VenkataRamana Add-ins for Outlook 1 July 9th 08 02:47 PM
Outlook Addin functions only one time after Outlook is started Mo Add-ins for Outlook 5 February 25th 08 02:44 PM
Addin call to external dll JahMic Add-ins for Outlook 3 April 10th 07 07:29 PM
Macro functions disabled? Sebastian Outlook and VBA 2 January 18th 07 09:01 AM
Call macro stored in Excel workbook from Outlook's macro Gvaram Outlook and VBA 5 October 4th 06 06:26 AM


All times are GMT +1. The time now is 08:17 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.