none
How can I finish a ribbon button control flow in the middle of that. RRS feed

  • Question

  • In MS Word VSTO custom ribbon tab, I have a button. 

    And it has some kind of long codes.

    I'd like to finish it at the some point.

    I could use the code below;

    System.Diagnostics.Process.GetCurrentProcess().Kill();   

    .

    But, It looks not so much good.

    Because, it kills MS Word itself too.

    .

    What is the better code could be ?

    .

    (Yeah, we have "goto" command here, but, you know,

    nobody recommends it, though I'm using it now.)

    .

    .

    Regards



    Sunday, February 22, 2015 1:10 PM

Answers

  • Hey daily using Word user,

    maybe a stupid guess but did you already tried to stop your method execution flow by returning from your button click event handler method using "return;" (in C#)?
     
    Regards,
    Thomas

    Sunday, February 22, 2015 3:28 PM

All replies

  • Hey daily using Word user,

    maybe a stupid guess but did you already tried to stop your method execution flow by returning from your button click event handler method using "return;" (in C#)?
     
    Regards,
    Thomas

    Sunday, February 22, 2015 3:28 PM
  • Really ? Is that so easy ?

    I'll check it out and let you know.

    Thanks.

    Sunday, February 22, 2015 3:40 PM
  • You are a bad one.

    You make me a stupid.

    It work fine.

    Thanks !!!

    Sunday, February 22, 2015 3:42 PM
  • Hello,

    > System.Diagnostics.Process.GetCurrentProcess().Kill();   

    The Word process will be killed in that case. Please remember that you develop an add-in, not a standalone application.

    > What is the better code could be ?

    You just need to release the flow of execution. Try to get out of the function returning the flow back to Office calling the return keyword (i.e. exit from a method)

    Sunday, February 22, 2015 3:45 PM
  • No worries and thanks for the quick feedback! :)

    Have a fine day,
    Thomas

    Sunday, February 22, 2015 4:07 PM
  • Yeah, You are right.

    That's the way to go.

    .

    Thanks again for your kind and helpful explanations.

    .

    Regards


    Sunday, February 22, 2015 10:39 PM