Exemplo n.º 1
0
 static bool IsFileOpenMenuEnabled()
 {
     CustomUI.CommandBars       commandBars    = CustomUI.ExcelCommandBarUtil.GetCommandBars();
     CustomUI.CommandBar        worksheetMenu  = commandBars[1]; // Worksheet Menu Bar
     CustomUI.CommandBarControl openMenuButton = worksheetMenu.FindControl(Missing.Value, /* ID:= */ 23, Missing.Value, Missing.Value, /* Recursive:= */ true);
     return(openMenuButton.Enabled);
 }
Exemplo n.º 2
0
        // This method contributed by Benoit Patra (see GitHub pull request: https://github.com/Excel-DNA/Excel-DNA/pull/1)
        // TODO: Still need to sort out the Id property
        //       This version is temporary, should behave the same as v.0.32
        private static CommandBar GetCommandBarFromIdOrName(Application excelApp, XmlAttributeCollection nodeAttributes, out string barName)
        {
            XmlAttribute name = nodeAttributes["name"];

            if (name == null)
            {
                throw new ArgumentException("CommandBar attributes must contain name");
            }
            barName = name.Value;

            CommandBar bar = null;

            for (int i = 1; i <= excelApp.CommandBars.Count; i++)
            {
                if (excelApp.CommandBars[i].Name == barName)
                {
                    bar = excelApp.CommandBars[i];
                    break;
                }
            }
            return(bar);
        }