Ahoj, mam kod, ve kterem ve wordu nahradim polozku v menu jinou polozkou :
oCommandBars = app.CommandBars;
Core.CommandBar oMenuBar = oCommandBars.ActiveMenuBar as Core.CommandBar;
object omissing = System.Reflection.Missing.Value;
Core.CommandBar oMenuBar = (Core.CommandBar)this.Application.CommandBars["Menu Bar"];
Core.CommandBarPopup oFormat = (Core.CommandBarPopup)oMenuBar.Controls["Formát"];
Core.CommandBarButton oColumns = (Core.CommandBarButton)oFormat.CommandBar.Controls["Sloupce ..."];
oColumns.Visible = false;
Core.CommandBarButton oCustom_Columns = (Core.CommandBarButton)oFormat.CommandBar.Controls.Add
(Core.MsoControlType.msoControlButton, omissing, omissing, oColumns.Index, 1);
oCustom_Columns.Caption = "Sloupce2 ...";
oCustom_Columns.Click += new Core._CommandBarButtonEvents_ClickEventHandler(oCustom_Columns_Click);
public void oCustom_Columns_Click(Core.CommandBarButton button_, ref bool cancel_)
{
//Your code to show custom Dialog box
}
funguje to skvele, ale porad se mi nedari vytvorit si vlastní menu a do nej nasazet vlastni polozky(funkce) , nemate s tim nekdo zkusenost ?
Ja to zkousim takto, ovsem vzdy se mi vytvori menu bez nazvu a bez polozky (funkce), cili prazdne menu. Nevite nekdo cim by to mohlo byt ??
Core.CommandBar oMenuBar = (Core.CommandBar)oCommandBars.ActiveMenuBar.Controls.Add(Core.MsoControlType.msoControlPopup, omissing, omissing, omissing, true);
oMenuBar.Name = "Test";
oMenuBar.Visible = true;
Core.CommandBarPopup oTest = (Core.CommandBarPopup)oMenuBar.Controls["Test"];
Core.CommandBarButton oLogin = (Core.CommandBarButton)oTest.CommandBar.Controls.Add(Core.MsoControlType.msoControlButton, omissing, omissing, omissing, omissing);
oLogin.Caption = "Login ...";
oLogin.Visible = true;