J
Jacques
Hello,
I am creating a menu for an Office Add-in.
The menu displays OK. But, each time I run
the Office App (Word) it adds another menu
item.
The Word menu bar looks like:
File | Edit | View |.. | My Menu | My Menu | My Menu |..
Do I have to "Find" the menu item first, to see if it
exist, before I create a new menu? If so, how do I
accomplish this?
InitMenuBarItems("&My Menu");
MenuItem1 = CreateButton(
(Office.CommandBarPopup)MenuBarItem,
"Menu Item 1");
private void InitMenuBarItems(string Caption)
{
try
{
MainMenuBar = wordApp.CommandBars["Menu Bar"];
MenuBarItem = MainMenuBar.Controls.Add(
Office.MsoControlType.msoControlPopup, Type.Missing,
Type.Missing, Type.Missing, true);
MenuBarItem.Caption = Caption;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Also, how do I create a separator bar between
menu items?
// I tried this and it displayed a single "-"
on the menu.
MenuItem2 = CreateButton(
(Office.CommandBarPopup)MenuBarItem,
"-");
TIA,
Jacques
I am creating a menu for an Office Add-in.
The menu displays OK. But, each time I run
the Office App (Word) it adds another menu
item.
The Word menu bar looks like:
File | Edit | View |.. | My Menu | My Menu | My Menu |..
Do I have to "Find" the menu item first, to see if it
exist, before I create a new menu? If so, how do I
accomplish this?
InitMenuBarItems("&My Menu");
MenuItem1 = CreateButton(
(Office.CommandBarPopup)MenuBarItem,
"Menu Item 1");
private void InitMenuBarItems(string Caption)
{
try
{
MainMenuBar = wordApp.CommandBars["Menu Bar"];
MenuBarItem = MainMenuBar.Controls.Add(
Office.MsoControlType.msoControlPopup, Type.Missing,
Type.Missing, Type.Missing, true);
MenuBarItem.Caption = Caption;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.Source,
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
Also, how do I create a separator bar between
menu items?
// I tried this and it displayed a single "-"
on the menu.
MenuItem2 = CreateButton(
(Office.CommandBarPopup)MenuBarItem,
"-");
TIA,
Jacques