none
VSTO...HOW TO!!! RRS feed

  • Question

  • Ok, I have made a ribbon in VS 2010. On a button press in the Ribbon I want the event to run a function in the ThisAddIn.vb file. This poses 2 questions:

     

    1) How do I run the external class?

    2) For the external class, what handler do I use? I don't know the events.

     

    For specifics, I am trying to 1) Replace some text and 2) Find some text and then highlight the text yellow.

    I would also like to find out how to highlight the text.

    Saturday, December 24, 2011 4:13 PM

Answers

  • Hi Tanu

    Why do you think you need events? In order to call code in the class ThisAddin from the Ribbon class no events are required. You just need to make sure that the method you want to call is "visible" outside the class (in other words, it can't be Private).


    Cindy Meister, VSTO/Word MVP
    Monday, December 26, 2011 7:25 AM
    Moderator

All replies

  • Hi Tanu Agg

    Your Ribbon is part of the same add-in as ThisAddIn.vb, correct? Not part of a different solution?

    If that's the case, then you can access any as PUBLIC or FRIEND defined methods using the Globals keyword. For example:
        Globals.ThisAddIn.FunctionName


    Cindy Meister, VSTO/Word MVP
    Sunday, December 25, 2011 8:40 AM
    Moderator
  • Thank you for that information, but the other question I have is what handler do I use for the class? Do I have to have a  event handler for the class in ThisAddIn.vb for it to be able to be run from Ribbon.vb?

    Yes, Ribbon.vb is in the same solution as ThisAddIn.vb.


    Tanu Agg-Director of Awesomeness and All things Nerdy
    Sunday, December 25, 2011 4:54 PM
  • Hi Tanu

    Why do you think you need events? In order to call code in the class ThisAddin from the Ribbon class no events are required. You just need to make sure that the method you want to call is "visible" outside the class (in other words, it can't be Private).


    Cindy Meister, VSTO/Word MVP
    Monday, December 26, 2011 7:25 AM
    Moderator