none
Accessing MS-Project's Application Object in Shared Add-in from c# RRS feed

  • Question

  • I am writing a shared add-in using c# and .net 4 for Office 2010. The add-in implements new ribbons in Word, Excel, PowerPoint, OutLook, Visio and MSProject.

    The following code (which uses the new dynamic keyword in C#)  works for all office applications except  MSProject where it returns a "System.NotImplementedException

    publicvoidOnConnection(objectapplication, Extensibility.ext_ConnectModeconnectMode, objectaddInInst, refSystem.Arraycustom)

            {

                dynamicapplicationObject = application;

                addInInstance = addInInst;

    try

                {

                    applicationName = applicationObject.Name;

                     MessageBox.Show(applicationName);

                }

    catch(Exceptionex)

                {

                  MessageBox.Show(ex.ToString());

                }

             }


    The add-in will be interacting heavily with the applications custom and built in properties so  use of "dynamic" will make life significantly easier or am I stuck with using reflection?


    • Edited by Rohan Salt Friday, November 16, 2012 3:57 AM
    Friday, November 16, 2012 3:56 AM

Answers

  • Hi Rohan,

    Sorry for late response.

    I would recommend you implement the Microsoft.Office.Interop.MSProject Namespace in your project and use such as "if(applicationObject is Microsoft.Office.Interop.MSProject.Application)" to detect whether the application instance is Microsoft Project.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 5, 2012 7:01 AM
    Moderator

All replies

  • Hi Rohan,

    Thanks for posting in the MSDN Forum.

    I can't reproduce your issue on my side. I suppose your un-checked Microsoft Project in the wizard. Would you create a new project and ensure Microsoft Project has been selected to reproduce your issue.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us

    Monday, November 19, 2012 5:18 AM
    Moderator
  • Tom,

    To make things a little easier, I have posted a copy of the application (which is still just s skeleton with just the UI implemented) at http://hillcrest.iinet.net.au/updates/ourdocs_client_addin.zip

    The shared add-in will load for Word, Excel, Powepoint, Outlook, Visio and MS Project. It will fail when trying to retrieve the Application "name" from the passed in Application Object when using the new c#.net 4 Dynamic keyword in Project but works happily for all the other products.

    The "name" property existis in MS Project because you can retrieve it via reflection ok ( the code to use reflection is provided but commented out in the above sample.)

    Hope this helps.

    Monday, November 19, 2012 6:34 AM
  • Hi Rohan,

    Sorry for late response.

    I would recommend you implement the Microsoft.Office.Interop.MSProject Namespace in your project and use such as "if(applicationObject is Microsoft.Office.Interop.MSProject.Application)" to detect whether the application instance is Microsoft Project.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 5, 2012 7:01 AM
    Moderator