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 » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

2003 add-in in Custom form



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 25th 08, 06:12 PM posted to microsoft.public.outlook.program_forms
GSK
external usenet poster
 
Posts: 17
Default 2003 add-in in Custom form

I have created a outlook 2003 add in VS 2005. I am referencing the add-in in
a custom outlook form. I am not able to call the Test method from the from,
am getting the error "object required". Pls find the code below. Kindly help
me in identifiying this issue.
--------------------------------------------------------------------------------------
Add-in Code :
namespace OutlookTest
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
public void Test(string Name)
{
MessageBox.Show(Name);
}
}
------------------------------------------------------------------------------------------
Custom form code
Function Item_Open()
Set myObj = Application.COMAddIns.Item("OutlookTest")
myObj.Connect = True
Set oCOMAddinObj = GetObject("","OutlookTest")
oCOMAddinObj.Test("Add-in call") /--Getting error in this line..
End Function
------------------------------------------------------------------------------------------
Ads
  #2  
Old February 26th 08, 03:04 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default 2003 add-in in Custom form

There's a lot more you need to do in a VSTO addin to make your addin code
available to outside calls. You need to override
RequestComAddInAutomationService() and provide a dual interface ComVisible
class, among other things.

You need something like this in your ThisAddIn class

private AddinUtilities addinUtilities;

protected override object RequestComAddInAutomationService()
{
if (addinUtilities == null)
{
addinUtilities = new AddinUtilities();
}
return addinUtilities;
}
}

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IAddinUtilities
{
void CalledFromOutside();
}

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class AddinUtilities : IAddinUtilities
{
// Demonstrates a method that can be called from outside the addin.
// This technique can be used to call functions and to read/write
properties.
public void CalledFromOutside()
{
MessageBox.Show("This is a test of an outside call to the COM
addin");
}
}
:
Then your calling code has to be specially formatted:

Dim oAddin

Set oAddin = Application.COMAddins.Item("myAddinProgID") ' myAddinProgID is
the ProgID of the addin
If Not (oAddin Is Nothing) Then
oAddin.Object.CalledFromOutside 'this calls the addin procedure
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


"GSK" wrote in message
...
I have created a outlook 2003 add in VS 2005. I am referencing the add-in
in
a custom outlook form. I am not able to call the Test method from the
from,
am getting the error "object required". Pls find the code below. Kindly
help
me in identifiying this issue.
--------------------------------------------------------------------------------------
Add-in Code :
namespace OutlookTest
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
public void Test(string Name)
{
MessageBox.Show(Name);
}
}
------------------------------------------------------------------------------------------
Custom form code
Function Item_Open()
Set myObj = Application.COMAddIns.Item("OutlookTest")
myObj.Connect = True
Set oCOMAddinObj = GetObject("","OutlookTest")
oCOMAddinObj.Test("Add-in call") /--Getting error in this line..
End Function
------------------------------------------------------------------------------------------

  #3  
Old February 26th 08, 07:14 PM posted to microsoft.public.outlook.program_forms
GSK
external usenet poster
 
Posts: 17
Default 2003 add-in in Custom form

Thanks very much Ken. It worked now after the changes.

"Ken Slovak - [MVP - Outlook]" wrote:

There's a lot more you need to do in a VSTO addin to make your addin code
available to outside calls. You need to override
RequestComAddInAutomationService() and provide a dual interface ComVisible
class, among other things.

You need something like this in your ThisAddIn class

private AddinUtilities addinUtilities;

protected override object RequestComAddInAutomationService()
{
if (addinUtilities == null)
{
addinUtilities = new AddinUtilities();
}
return addinUtilities;
}
}

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface IAddinUtilities
{
void CalledFromOutside();
}

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
public class AddinUtilities : IAddinUtilities
{
// Demonstrates a method that can be called from outside the addin.
// This technique can be used to call functions and to read/write
properties.
public void CalledFromOutside()
{
MessageBox.Show("This is a test of an outside call to the COM
addin");
}
}
:
Then your calling code has to be specially formatted:

Dim oAddin

Set oAddin = Application.COMAddins.Item("myAddinProgID") ' myAddinProgID is
the ProgID of the addin
If Not (oAddin Is Nothing) Then
oAddin.Object.CalledFromOutside 'this calls the addin procedure
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


"GSK" wrote in message
...
I have created a outlook 2003 add in VS 2005. I am referencing the add-in
in
a custom outlook form. I am not able to call the Test method from the
from,
am getting the error "object required". Pls find the code below. Kindly
help
me in identifiying this issue.
--------------------------------------------------------------------------------------
Add-in Code :
namespace OutlookTest
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
public void Test(string Name)
{
MessageBox.Show(Name);
}
}
------------------------------------------------------------------------------------------
Custom form code
Function Item_Open()
Set myObj = Application.COMAddIns.Item("OutlookTest")
myObj.Connect = True
Set oCOMAddinObj = GetObject("","OutlookTest")
oCOMAddinObj.Test("Add-in call") /--Getting error in this line..
End Function
------------------------------------------------------------------------------------------


 




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
place .NET custom control on custom form in Outlook 2003 and Outlook 2007 sd[_2_] Outlook and VBA 7 October 11th 07 06:44 PM
Populate Outlook 2003 Custom Form from Access 2003 Kujp Sucisv Outlook - Using Forms 1 May 21st 07 09:20 PM
custom form in otulook 2003 armando cazzetta Outlook and VBA 0 November 2nd 06 09:27 AM
custom form in otulook 2003 armando cazzetta Outlook and VBA 0 November 2nd 06 09:25 AM
Is it possible to open the default Contact form with the Activities tab activated from a custom form? VSTO 2005, Outlook 2003 David Webb Outlook and VBA 1 June 20th 06 09:59 PM


All times are GMT +1. The time now is 06:36 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.