locked
Hidinh tab on ribbon Load RRS feed

  • Question

  • Hi,

    In my recnt project i came up with the following scenario

    1. show/hide the tab in ribbon based on some condition.

    2.I tried to add validation and to set visible property of tab in ribbon_load event.But it does not worked out for me

    3.Are we able to set the tab property in ribbon load event .If No can some one help me with sample to rectify?

    Thursday, September 12, 2013 9:22 AM

Answers

  • Quite likely, there's no document open when the Ribbon is loading. And since you're not doing anything with errors in the catch block, you're not seeing any errors...

    If that's the case, then try using the DocumentOpen event instead of RibbonLoad.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by George Hua Friday, September 20, 2013 6:01 PM
    Friday, September 13, 2013 1:55 PM

All replies

  • private void GetFileName()
            {
                string[] inputList = new string[] { };
                char[] separator = { ',' };
                string result;
                int s;
                try
                {
                    fullName =  Globals.ThisAddIn.Application.ActiveDocument.Name;
                    result = Path.GetFileNameWithoutExtension(fullName);
                    inputList = result.Split(separator);
                    if (inputList.Length == 4)
                    {
                        docID = inputList[0];
                        versionID = inputList[1];
                        name = inputList[2];
                        flag = inputList[3];
                    }
                    if (!string.IsNullOrEmpty(flag))
                    {
                        s= string.Compare(flag,"TEST",true);
                        if (s==0)
                        {
                            EnableTab(true);
                        }
                        else
                        {
                            EnableTab(false);
                        }
                    }
                }
                catch (Exception ex)
                {
                }       
            }
    This is my function and it works good when i call it in some click event but not works as expected on ribbon load event.Can some one tell me what is the wrong in it?
    Thursday, September 12, 2013 1:25 PM
  • Quite likely, there's no document open when the Ribbon is loading. And since you're not doing anything with errors in the catch block, you're not seeing any errors...

    If that's the case, then try using the DocumentOpen event instead of RibbonLoad.


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by George Hua Friday, September 20, 2013 6:01 PM
    Friday, September 13, 2013 1:55 PM
  • Exactly the document open helped me.But since i was busy i cannot post the info into the forum.

    Anways thanks for your reply Cindy!

    Saturday, September 14, 2013 4:36 AM