Passing value as VariantIn to IDTCommandTarget.Exec RRS feed

  • Question

  • I have a CommandBarButton that, when clicked, I would like to pass a specific value to IDTCommandTarget.Exec's VariantIn parameter.  I have tried several things, including setting the CommandBarButton's Parameter property, but no go.  Of course it's not that simple, rarely is...so could someone please shed a little light on how to do this?


    The end result is that I want the same Command to be executed but determine whether to show or hide a piece of the UI during execution of the command.  I know I can do this with two separate commands, but I would prefer a single command.



    Tuesday, July 20, 2010 9:57 PM


  • Hello Mythran,


    Thanks for your post.

    I guess you want to control the command visibility by itself.

    Have you tried delegate _dispCommandEvents_BeforeExecuteEventHandler?

    Here is the sample:


    CommandEvents saveEvents;

    saveEvents = _applicationObject.Events.get_CommandEvents("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 331);

    saveEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(saveEvents_BeforeExecute);

    //function defination

    private void saveEvents_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault)



    Which you can refer to the post:


    You can change the visibility in QueryStatus() and set the parameter in both Exec() and saveEvents_BeforeExecute().

    If I misunderstand you, be free to let me know.




    Best Regards,

    Ziwei Chen


    • Marked as answer by Victor_Chen Tuesday, July 27, 2010 8:10 AM
    Friday, July 23, 2010 3:37 AM