msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

2003 add-in in Custom form

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program Forms
Author Message
GSK



Joined: 28 Aug 2007
Posts: 12

PostPosted: Mon Feb 25, 2008 3:12 pm    Post subject: 2003 add-in in Custom form Reply with quote

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
------------------------------------------------------------------------------------------

Archived from group: microsoft>public>outlook>program_forms
Back to top
View user's profile Send private message
Ken Slovak - [MVP - Outlo



Joined: 12 Aug 2007
Posts: 405

PostPosted: Tue Feb 26, 2008 3:04 pm    Post subject: Re: 2003 add-in in Custom form Reply with quote

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 @microsoft.com...
>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
> ------------------------------------------------------------------------------------------
Back to top
View user's profile Send private message
GSK



Joined: 28 Aug 2007
Posts: 12

PostPosted: Tue Feb 26, 2008 4:14 pm    Post subject: Re: 2003 add-in in Custom form Reply with quote

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
> @microsoft.com...
> >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
> > ------------------------------------------------------------------------------------------
>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Custom Message Form Hello, I'd like to be able to send a question form as a message to our employees. My idea is that the employee enters the answers and replies to me. I then want to have the Qs & As in a format that can easily be copied into another system's Rich text box.

Can't Find Custom Form My head aches!! I created a custom form and called it huh?). I published it as a contact form and now when I go to choose a form and select the contacts folder I don't see my form. Have no idea where to look, when or how. -- James

Custom Appointment Form I've added fields to a custom appointment form for equipment like a laptop and projector. When the appointment is sent, I want an email for the form to also be sent to my desktop support team telling them when and where the meeting is, and that a laptop

Custom Form Forcing Save On my form I have the following code: Function Item_Write() If <> "" Then If <> "" Then Item.FileAs = & vbcrlf & _

Custom Message Form - Customization Hi All, I am working with Custom Forms, now i am wondering how to complete my actual tasks. I need to create a vacation request process in outlook, similar to the one which the Microsoft sample Forms. But i will be getting the information like Vacation d
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program Forms All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group