views:

2158

answers:

2

I'm having some trouble understanding Outlook terms (CommandBarPopup, CommandBarButton etc) like what is what in Outlook so please be patient.

I would like to create couple of things:

  1. I would like to create new group (or just button but i read it's not possible to add a button to an existing group in ribbon) on new mail next to Signature/Add attachment in Message Ribbon. It would have to work the same way Signature works so when you press it it display couple of options. How can i create it?

  2. I would like to override a button "NEW" (where you can choose that you want to send new mail, make appointment or do other things) so that when you are in Main Window when you press the down arrow next to new button you could choose one of options i will add? Is this possible? How do I do it?

  3. I have some code that adds a menu in Main Window

    private void AddMenuBar() {
        try {
            //Define the existent Menu Bar
            menuBar = this.Application.ActiveExplorer().CommandBars.ActiveMenuBar;
            //Define the new Menu Bar into the old menu bar
            newMenuBar = (Office.CommandBarPopup) menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, missing, missing, missing, false);
            //If I dont find the newMenuBar, I add it
            if (newMenuBar != null) {
                newMenuBar.Caption = "Test";
                newMenuBar.Tag = menuTag;
                buttonOne = (Office.CommandBarButton) newMenuBar.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, 1, true);
                buttonOne.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                buttonOne.Caption = "Test Button";
                //This is the Icon near the Text
                buttonOne.FaceId = 610;
                buttonOne.Tag = "c123";
                //Insert Here the Button1.Click event    
                buttonOne.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonOneClick);
                newMenuBar.Visible = true;
            }
        } catch (Exception ex) {
            //This MessageBox is visible if there is an error
            System.Windows.Forms.MessageBox.Show("Error: " + ex.Message.ToString(), "Error Message Box", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
    }
    

I would like to add submenu under the buttonOne so when i press it new submenus open up. How do I achieve that?

+1  A: 

Hi,

  1. Is not possible in that the OOM does not expose this type of button :( even though MS use it. You can though hide a Button group and then create your own "similar" group by adding standard Commands, kinda giving you the same thing.

EDIT: XML to hide standard Action group .. using its visible property and its idMso

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load" loadImage="GetImage">
  <ribbon>
    <tabs>
      <tab idMso="TabReadMessage">
        <group idMso="GroupActions" visible="false">   
        </group>

        <group id="newactionsgroup" label="Actions" insertAfterMso="GroupActions">
          <button idMso="Delete" size="large"/>
          <button id="MoveToFolder" imageMso="MoveToFolder" size="large" label="Move To Folder" onAction="myMoveToFolder" />
          <button idMso="CreateMailRule" size="large"/>
          <menu idMso="OtherActionsMenu" size="large"/>
        </group>
     </tab>
    </tabs>
  </ribbon>
</customUI>
  1. Not possible at all though you can again hide the existing button and create something similar with a well position form !

3.Create your buttonOne as a CommandBarPopup

76mel
Do you have an example on how to Hide a button group and add my own (i have no idea how to create grp and those buttons).
MadBoy
have added some ribbon xml for you to hide the standard group and recreat your own.
76mel
Thanks, although i will prolly spent some time till i get it to work ;) I really need to read some books about it first :)
MadBoy
http://msdn.microsoft.com/en-us/library/aa942866(VS.80).aspx is a good place to start
76mel
+1  A: 

I don't know if this is what you are looking for in your second point, but I managed to add a custom menu item to the "New" button dropdown with the following code:

  private void AddButtonToNewDropdown()
    {
        Office.CommandBar commandBar = this.Application.ActiveExplorer().CommandBars["Standard"];
        Office.CommandBarControl ctl = commandBar.Controls["&New"];
        if (ctl is Office.CommandBarPopup)
        {
            Office.CommandBarPopup newpopup = (Office.CommandBarPopup)ctl;
            commandBarButton = (Office.CommandBarButton)newpopup.Controls.Add(1, missing, missing, missing, true);
            commandBarButton.Caption = "My custom button";
            commandBarButton.Click += new Office._CommandBarButtonEvents_ClickEventHandler(ButtonClick);
        }

    }
neuro
MadBoy
Also how do i delete such created button ? :)
MadBoy