none
Need C# code to detect what Office app. is active for Ribbon RRS feed

  • Question

  • Hi

    I have an MSOffice Ribbon solution (built in VSTO using C#), which uses a class library shared between Excel and Outlook projects in the solution.
    The Ribbon currently is the exact same in both Excel and Outlook (because they both use the shared class lib.)
    However, I'd like to add another button to the Ribbon which will open a different hyperlink depending on whether it is clicked in Excel, or Outlook.

    So I think I need a segment of C# switch code that will open a certain hyperlink depending on the Office environment (Excel or Outlook) it is clicked from.

    In other words, if someone is using the custom Ribbon while in Outlook, it will open an Outlook help page, if someone is using the custom Ribbon while in Excel, it will open an Excel help page.

    Appreciate  for any suggestions!

    Fergal

    Monday, March 4, 2013 4:18 PM

Answers

  • In either case you can get the Applicatfion object exposed in Globals.ThisAddIn.Application and use the Application.Name property to identify where the code is running.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Fergal Kilkenny" <=?utf-8?B?RmVyZ2FsIEtpbGtlbm55?=> wrote in message news:bee8e8fc-403a-471c-8b15-e408eb28d573...

    Hi

    I have an MSOffice Ribbon solution (built in VSTO using C#), which uses a class library shared between Excel and Outlook projects in the solution.
    The Ribbon currently is the exact same in both Excel and Outlook (because they both use the shared class lib.)
    However, I'd like to add another button to the Ribbon which will open a different hyperlink depending on whether it is clicked in Excel, or Outlook.

    So I think I need a segment of C# switch code that will open a certain hyperlink depending on the Office environment (Excel or Outlook) it is clicked from.

    In other words, if someone is using the custom Ribbon while in Outlook, it will open an Outlook help page, if someone is using the custom Ribbon while in Excel, it will open an Excel help page.

    Appreciate  for any suggestions!

    Fergal


    Ken Slovak MVP - Outlook
    Monday, March 4, 2013 6:22 PM