![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |