none
outlook 2010 ribbon customzation RRS feed

  • Question

  • HI, Everybody,

    I want to add my own ribbon on outlook 2010 calendar view and main view, and my way is add code in GetCustomUI function as below:

    // for main view
    *RibbonXml = SysAllocString(
    		_T("<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">")
    		_T("  <ribbon>")
    		_T("    <tabs>")
    	    _T("      <tab idMso=\"TabMail\">")
    		_T("        <group id=\"Conf\"")
    		_T("               label=\"tab1\"")
    		_T("               insertBeforeMso=\"GroupMove\">")
    		_T("          <button id=\"AddConf\" ")
    	    _T("                  size=\"large\" ")
    		_T("                  label=\"tab2\"")
    		_T("                  getImage=\"OnGetImage\"")
    		_T("                  onAction=\"OnRibbonBtnReserveConf\"/>")
    		_T("          <dynamicMenu id=\"MoreOptions\"")
    		_T("                       size=\"large\" ")
    		_T("                       label=\"tab3\"") 
    		_T("                       getImage=\"OnGetImageOption\"") 
    		_T("                       getContent=\"OnRibbonBtnMore\"/>")
    		_T("      </group>")
    		_T("   </tab>")
    		_T("  </tabs>")
    		_T(" </ribbon>")
    		_T("</customUI>")
    		);
    
    // for canlendar viwe
    if (strRibbonID.CompareNoCase(_T("Microsoft.Outlook.Calendar")) == 0)
    	{
    		//*RibbonXml = GetXMLResource(IDR_XML2);  
    		*RibbonXml = SysAllocString(
    			_T("<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\" onLoad=\"OnRibbonLoad\">")
    			_T("  <ribbon>")
    			_T("    <tabs>")
    			_T("      <tab idMso=\"TabAppointment\">")
    			_T("        <group id=\"Conf\" ")
    			_T("               label=\"tab1\"")
    			_T("               insertAfterMso=\"GroupShow\">")
    			_T("          <button id=\"AddConf\" ")
    		    _T("                  size=\"large\" ")
    			_T("                  label=\"tab2\"")
    			_T("                  getImage=\"OnGetImage\"")
    			_T("                  onAction=\"OnCreateConf\"")
    			_T("                  getVisible=\"OnGetVisibilityOfCreate\"/>")
    			_T("          <button id=\"CancelQuanshiConf\" ")
    			_T("                  size=\"large\" ")
    			_T("                  label=\"tab3\"")
    			_T("                  getImage=\"OnGetImageCancel\"")
    			_T("                  onAction=\"OnCancelConf\"")
    			_T("                  getVisible=\"OnGetVisibilityOfCancel\"/>")
    			_T("      </group>")
    			_T("   </tab>")
    			_T("  </tabs>")
    			_T(" </ribbon>")
    			_T("</customUI>")
    			);

    And it is managed to show the ribbon I insert in main view but failed in calendar view, I debug it and found that when I change the view from main view to calendar view, the program will not step in the function OnCustomUI.

    Perhaps someone is familiar with it and can lead me in a right way.

    Thanks.


    • Edited by SaraZC Saturday, June 16, 2012 3:18 AM
    Saturday, June 16, 2012 3:17 AM

Answers

  • where did you get Microsoft.Outlook.Calendar as a valid ribbon identifier? could you show us article where this was decribed?
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Saturday, June 16, 2012 11:04 AM
  • Usually to make customizations to explorer you respond to Microsoft.Outlook.Explorer and provide there your xml. Now to make that context specific (show/hide buttons, etc.) you define in your ribbon xml callbacks and attach yourself to proper events (for example FolderSwitch on explorer) and call Invalidate/InvalidateControl on ribbon object there.

    As for ribbonIds, please consult documentation for valid values.

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Monday, June 18, 2012 2:22 PM
  • Hi, DamianD,

    Thanks for answering my questions, and I found you know the outlook well, can me get your msn so perhaps we can communicate better than now. My msn is SaraZ_26@hotmail. Of course you can ignore it if you hate to be  bothered in your personel time.

    Best wishes.

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Monday, June 18, 2012 2:42 PM
  • invalidate call causes your callbacks defined on buttons to be called again, not your customUI. So in customui in request to provide explorer customizations return xml that defines all buttons that you want to have there with callbacks to show/hide them (getVisible). Attach also to all events that you need to provide contextual changes with your buttons and call invalidate on ribbon object when proper event arises.

    I have nothing against personal contact but i guess it would be better to answer your problems here so all other can also benefit from it. 

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Monday, June 18, 2012 3:02 PM
  • if by calendar view you mean view that is displayed in outlook's explorer when you click calendar in navigation pane, then you have to handle "

    Microsoft.Outlook.Explorer" (last option in your list) and listen to FolderSwitch event on explorer to detect that now calendar is displayed and call InvalidateControl on ribbon object so your callbacks will be called again and you can determine if your buttons should be shown.

    OR

    in outlook 2010 you could use contextual tabs (http://msdn.microsoft.com/en-us/library/windows/desktop/ee264329(v=vs.85).aspx) to 'attach' your buttons to tabs that will be only shown for calendar view.

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Tuesday, July 10, 2012 7:22 AM
  • Explorer.FolderSwitch() or Explorer.BeforeFolderSwitch(), either would do. Check for Explorer.CurrentFolder type. Call Invalidate() on the Ribbon and in a getVisible() callback decide whether or not to make your controls visible.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:e726efa5-73b1-47d9-855c-98e712ff776e...

    Thanks Damian.

    Can I ask a question?

    You suggested two ways and which one is easier? I am in a rush time now.

    And does FolderSwitch event mean FolderChange event?

    Thanks.


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Tuesday, July 10, 2012 2:17 PM
  • I'm not sure where you're looking, I just used OLEView and get this:
     

            [id(0x0000f002), helpcontext(0x0000007d)]

            void FolderSwitch();

     

            [id(0x0000f003), helpcontext(0x0000007e)]

            void BeforeFolderSwitch(

            [in] IDispatch* NewFolder,

            [in, out] VARIANT_BOOL* Cancel);

    Then, for ZExplorer_Events10 I get this:
     

    [

    uuid(0006300F-0000-0000-C000-000000000046),

    helpcontext(0x000001c0)

    ]

    dispinterface ExplorerEvents_10 {

    properties:

    methods:

    [id(0x0000f001), helpcontext(0x000001c1)]

    HRESULT Activate();

    [id(0x0000f002), helpcontext(0x000001c2)]

    HRESULT FolderSwitch();

    [id(0x0000f003), helpcontext(0x000001c3)]

    HRESULT BeforeFolderSwitch(

    [in] IDispatch* NewFolder,

    [in, out] VARIANT_BOOL* Cancel);

    [id(0x0000f004), helpcontext(0x000001c4)]

    HRESULT ViewSwitch();

    [id(0x0000f005), helpcontext(0x000001c5)]

    HRESULT BeforeViewSwitch(

    [in] VARIANT NewView,

    [in, out] VARIANT_BOOL* Cancel);

    [id(0x0000f006), helpcontext(0x000001c6)]

    HRESULT Deactivate();

    [id(0x0000f007), helpcontext(0x000001c7)]

    HRESULT SelectionChange();

    [id(0x0000f008), helpcontext(0x000001c8)]

    HRESULT Close();

    [id(0x0000fa11), helpcontext(0x000001c9)]

    HRESULT BeforeMaximize([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa12), helpcontext(0x000001ca)]

    HRESULT BeforeMinimize([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa13), helpcontext(0x000001cb)]

    HRESULT BeforeMove([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa14), helpcontext(0x000001cc)]

    HRESULT BeforeSize([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa0e), helpcontext(0x000001cd)]

    void BeforeItemCopy([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa0f), helpcontext(0x000001ce)]

    void BeforeItemCut([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa10), helpcontext(0x000001cf)]

    void BeforeItemPaste(

    [in] VARIANT* ClipboardContent,

    [in] MAPIFolder* Target,

    [in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fc79), helpcontext(0x00000d9b)]

    HRESULT AttachmentSelectionChange();

    };


    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:41071c74-4911-4a35-9495-be77c479a74e...

    And another question,  I write the add-in in c++, and when I connect the event to outlook, I need to know the dispid of the event first.

    I can't find the dispid of FolderSwitch event, I checked the MSOUTL.OLB file with OleView.Exe, and turns out there is no information about exploer's.

    Here is the screen-shot of the checked result.


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Wednesday, July 11, 2012 2:54 PM
  • Your ribbon code specifies that it should only be used for "TabMail". That is only shown for a mail folder, not for a calendar folder.
     
    Use the correct tab id, and if you want your UI shown when in more than 1 module you need to create ribbon XML for each tab you want to work with.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:2f01e817-bc7e-4252-83f0-3c8153ee65e7...

    I am sure GetCustomUI is called, and the code to put ribbon is called too as below:

    *RibbonXml = SysAllocString(
    		_T("<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">")
    		_T("  <ribbon>")
    		_T("    <tabs>")
    	    _T("      <tab idMso=\"TabMail\">")
    		_T("        <group id=\"QuanshiConf\"")
    		_T("               label=\"tool\"")
    		_T("               insertBeforeMso=\"GroupMove\">")
    		_T("          <button id=\"AddQuanshiConf\" ")
    	    _T("                  size=\"large\" ")
    		_T("                  label=\"tool1\"")
    		_T("                  getImage=\"OnGetImage\"")
    		_T("                  onAction=\"OnRibbonBtnReserveConf\"/>")
    		_T("          <dynamicMenu id=\"MoreOptions\"")
    		_T("                       size=\"large\" ")
    		_T("                       label=\"tool2\"") 
    		_T("                       getImage=\"OnGetImageOption\"") 
    		_T("                       getContent=\"OnRibbonBtnMore\"/>")
    		_T("      </group>")
    		_T("   </tab>")
    		_T("  </tabs>")
    		_T(" </ribbon>")
    		_T("</customUI>")
    		);


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Wednesday, July 11, 2012 2:54 PM
  • Sorry, that I can't help with. Hopefully someone who does more C++ type stuff will review this thread or the other one you started and jump in. If not, I'll ask someone to take a look at the thread.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:4b9978ab-d0c2-4abc-b895-179a95d8162e...

    I tried 0x0000f002,  and it made no difference, the error is still there.

    So confused. I don't know what I missed or What I did wrong........


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Thursday, July 12, 2012 3:00 PM
  • i think we already had this conversation - getcustomui is called only once and nothing can make outlook to call it again (short of unloading and loading your add-in). You control visibility of your buttons by callbacks, but of course if you want to place your buttons inside standard tabs and groups you better make sure that they are shown at all in your desired situation. If you want your buttons to appear in main tab despite inbox or calendar view you should add them to both places.
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Friday, July 13, 2012 10:04 AM
  • 2 things:

    1. check value of ribbonId, you should only return your xml when outlook asks for "Microsoft.Outlook.Explorer"

    2. Combine your 2 strings into one valid xml (remove redundant enclosing tags) so it should be like:

    <customUI>

    <ribbon>

    <tabs>

    <tab>

    </tab>

    <tab>

    ...etc.

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Friday, July 13, 2012 12:09 PM
  • first of all - ids cannot be the same so rename them,

    second - groupMove might not exist but this is a minor problem since it will make your buttons appear at the end of whole ribbon

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:50 AM
    Friday, July 13, 2012 1:23 PM

All replies

  • No reply for long time, is it because I describe it in a complex way?

    ok, let me simplify the question:

    How to add ribbon in outlook 2010 in calendar view with c++ addin?

    Saturday, June 16, 2012 10:21 AM
  • where did you get Microsoft.Outlook.Calendar as a valid ribbon identifier? could you show us article where this was decribed?
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Saturday, June 16, 2012 11:04 AM
  • Thanks DamianD,

    I used Microsoft.Outlook.Calenda because Microsoft.Outlook.Appointment works in my code.

    And I think perhaps it is not the point now, I can't get what I want even if Microsoft.Outlook.Calendar is a valid ribbon, I want to know how to make GetCustomUI works when I change the current folder from inbox to calendar so I can add myself's ribbon.

    Thanks.

    Monday, June 18, 2012 2:09 PM
  • Usually to make customizations to explorer you respond to Microsoft.Outlook.Explorer and provide there your xml. Now to make that context specific (show/hide buttons, etc.) you define in your ribbon xml callbacks and attach yourself to proper events (for example FolderSwitch on explorer) and call Invalidate/InvalidateControl on ribbon object there.

    As for ribbonIds, please consult documentation for valid values.

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Monday, June 18, 2012 2:22 PM
  • Dear DamianD,

    Thanks first.

    I tried Invalidate and find that it doesn't  lead a call to GetCustomUI........

    Monday, June 18, 2012 2:33 PM
  • Hi, DamianD,

    Thanks for answering my questions, and I found you know the outlook well, can me get your msn so perhaps we can communicate better than now. My msn is SaraZ_26@hotmail. Of course you can ignore it if you hate to be  bothered in your personel time.

    Best wishes.

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Monday, June 18, 2012 2:42 PM
  • invalidate call causes your callbacks defined on buttons to be called again, not your customUI. So in customui in request to provide explorer customizations return xml that defines all buttons that you want to have there with callbacks to show/hide them (getVisible). Attach also to all events that you need to provide contextual changes with your buttons and call invalidate on ribbon object when proper event arises.

    I have nothing against personal contact but i guess it would be better to answer your problems here so all other can also benefit from it. 

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Monday, June 18, 2012 3:02 PM
  • Thanks.

    I see your point,  and I will try in your way to see if it works, and if it succeed, I will describe the exact way here.

    Thanks for your help, and I'd really appreciate it.

    Regards.

    Monday, June 18, 2012 3:25 PM
  • Hi, Damian,

    I can't find the ribbon id for outlook 2010 calendar view.

    This is the information I checked:

    Ribbon ID

    Message class

    Microsoft.OMS.MMS.Compose

    IPM.Note.Mobile.MMS.*

    Microsoft.OMS.MMS.Read

    IPM.Note.Mobile.MMS.*

    Microsoft.OMS.SMS.Compose

    IPM.Note.Mobile.SMS.*

    Microsoft.OMS.SMS.Read

    IPM.Note.Mobile.SMS.*

    Microsoft.Outlook.Appointment

    IPM.Appointment.*

    Microsoft.Outlook.Contact

    IPM.Contact.*

    Microsoft.Outlook.DistributionList

    IPM.DistList.*

    Microsoft.Outlook.Journal

    IPM.Activity.*

    Microsoft.Outlook.Mail.Compose

    IPM.Note.*

    Microsoft.Outlook.Mail.Read

    IPM.Note.*

    Microsoft.Outlook.MeetingRequest.Read

    IPM.Schedule.Meeting.Request or IPM.Schedule.Meeting.Canceled

    Microsoft.Outlook.MeetingRequest.Send

    IPM.Schedule.Meeting.Request

    Microsoft.Outlook.Post.Compose

    IPM.Post.*

    Microsoft.Outlook.Post.Read

    IPM.Post.*

    Microsoft.Outlook.Report

    IPM.Report.*

    Microsoft.Outlook.Resend

    IPM.Resend.*

    Microsoft.Outlook.Response.Compose

    IPM.Schedule.Meeting.Resp.*

    Microsoft.Outlook.Response.CounterPropose

    IPM.Schedule.Meeting.Resp.*

    Microsoft.Outlook.Response.Read

    IPM.Schedule.Meeting.Resp.*

    Microsoft.Outlook.RSS

    IPM.Post.Rss.*

    Microsoft.Outlook.Sharing.Compose

    IPM.Sharing.*

    Microsoft.Outlook.Sharing.Read

    IPM.Sharing.*

    Microsoft.Outlook.Task

    IPM.Task.* and IPM.TaskRequest.*

    Microsoft.Outlook.Explorer

    Not applicable. Use this ribbon ID to return XML markup for explorer ribbons, context menus, and Backstage view.

    Tuesday, July 10, 2012 2:52 AM
  • if by calendar view you mean view that is displayed in outlook's explorer when you click calendar in navigation pane, then you have to handle "

    Microsoft.Outlook.Explorer" (last option in your list) and listen to FolderSwitch event on explorer to detect that now calendar is displayed and call InvalidateControl on ribbon object so your callbacks will be called again and you can determine if your buttons should be shown.

    OR

    in outlook 2010 you could use contextual tabs (http://msdn.microsoft.com/en-us/library/windows/desktop/ee264329(v=vs.85).aspx) to 'attach' your buttons to tabs that will be only shown for calendar view.

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Tuesday, July 10, 2012 7:22 AM
  • Thanks Damian.

    Can I ask a question?

    You suggested two ways and which one is easier? I am in a rush time now.

    And does FolderSwitch event mean FolderChange event?

    Thanks.

    Tuesday, July 10, 2012 9:36 AM
  • Explorer.FolderSwitch() or Explorer.BeforeFolderSwitch(), either would do. Check for Explorer.CurrentFolder type. Call Invalidate() on the Ribbon and in a getVisible() callback decide whether or not to make your controls visible.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:e726efa5-73b1-47d9-855c-98e712ff776e...

    Thanks Damian.

    Can I ask a question?

    You suggested two ways and which one is easier? I am in a rush time now.

    And does FolderSwitch event mean FolderChange event?

    Thanks.


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:48 AM
    Tuesday, July 10, 2012 2:17 PM
  • I set in outlook to make the default folder to be calendar, and it is supposed to load my ribbon when startup. But the fact is it doesn't work at all.

    I am confused since it works when the default folder is mail, why doesn't in calendar?

    Thanks all.

    Wednesday, July 11, 2012 8:47 AM
  • what does not work at all? is your GetCustomUI not called?
    Wednesday, July 11, 2012 2:07 PM
  • I am sure GetCustomUI is called, and the code to put ribbon is called too as below:

    *RibbonXml = SysAllocString(
    		_T("<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">")
    		_T("  <ribbon>")
    		_T("    <tabs>")
    	    _T("      <tab idMso=\"TabMail\">")
    		_T("        <group id=\"QuanshiConf\"")
    		_T("               label=\"tool\"")
    		_T("               insertBeforeMso=\"GroupMove\">")
    		_T("          <button id=\"AddQuanshiConf\" ")
    	    _T("                  size=\"large\" ")
    		_T("                  label=\"tool1\"")
    		_T("                  getImage=\"OnGetImage\"")
    		_T("                  onAction=\"OnRibbonBtnReserveConf\"/>")
    		_T("          <dynamicMenu id=\"MoreOptions\"")
    		_T("                       size=\"large\" ")
    		_T("                       label=\"tool2\"") 
    		_T("                       getImage=\"OnGetImageOption\"") 
    		_T("                       getContent=\"OnRibbonBtnMore\"/>")
    		_T("      </group>")
    		_T("   </tab>")
    		_T("  </tabs>")
    		_T(" </ribbon>")
    		_T("</customUI>")
    		);

    Wednesday, July 11, 2012 2:17 PM
  • And another question,  I write the add-in in c++, and when I connect the event to outlook, I need to know the dispid of the event first.

    I can't find the dispid of FolderSwitch event, I checked the MSOUTL.OLB file with OleView.Exe, and turns out there is no information about exploer's.

    Here is the screen-shot of the checked result.

    Wednesday, July 11, 2012 2:22 PM
  • in calendar view TabMail is hidden, try idMso="TabAppointment"
    Wednesday, July 11, 2012 2:37 PM
  • I'm not sure where you're looking, I just used OLEView and get this:
     

            [id(0x0000f002), helpcontext(0x0000007d)]

            void FolderSwitch();

     

            [id(0x0000f003), helpcontext(0x0000007e)]

            void BeforeFolderSwitch(

            [in] IDispatch* NewFolder,

            [in, out] VARIANT_BOOL* Cancel);

    Then, for ZExplorer_Events10 I get this:
     

    [

    uuid(0006300F-0000-0000-C000-000000000046),

    helpcontext(0x000001c0)

    ]

    dispinterface ExplorerEvents_10 {

    properties:

    methods:

    [id(0x0000f001), helpcontext(0x000001c1)]

    HRESULT Activate();

    [id(0x0000f002), helpcontext(0x000001c2)]

    HRESULT FolderSwitch();

    [id(0x0000f003), helpcontext(0x000001c3)]

    HRESULT BeforeFolderSwitch(

    [in] IDispatch* NewFolder,

    [in, out] VARIANT_BOOL* Cancel);

    [id(0x0000f004), helpcontext(0x000001c4)]

    HRESULT ViewSwitch();

    [id(0x0000f005), helpcontext(0x000001c5)]

    HRESULT BeforeViewSwitch(

    [in] VARIANT NewView,

    [in, out] VARIANT_BOOL* Cancel);

    [id(0x0000f006), helpcontext(0x000001c6)]

    HRESULT Deactivate();

    [id(0x0000f007), helpcontext(0x000001c7)]

    HRESULT SelectionChange();

    [id(0x0000f008), helpcontext(0x000001c8)]

    HRESULT Close();

    [id(0x0000fa11), helpcontext(0x000001c9)]

    HRESULT BeforeMaximize([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa12), helpcontext(0x000001ca)]

    HRESULT BeforeMinimize([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa13), helpcontext(0x000001cb)]

    HRESULT BeforeMove([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa14), helpcontext(0x000001cc)]

    HRESULT BeforeSize([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa0e), helpcontext(0x000001cd)]

    void BeforeItemCopy([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa0f), helpcontext(0x000001ce)]

    void BeforeItemCut([in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fa10), helpcontext(0x000001cf)]

    void BeforeItemPaste(

    [in] VARIANT* ClipboardContent,

    [in] MAPIFolder* Target,

    [in, out] VARIANT_BOOL* Cancel);

    [id(0x0000fc79), helpcontext(0x00000d9b)]

    HRESULT AttachmentSelectionChange();

    };


    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:41071c74-4911-4a35-9495-be77c479a74e...

    And another question,  I write the add-in in c++, and when I connect the event to outlook, I need to know the dispid of the event first.

    I can't find the dispid of FolderSwitch event, I checked the MSOUTL.OLB file with OleView.Exe, and turns out there is no information about exploer's.

    Here is the screen-shot of the checked result.


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Wednesday, July 11, 2012 2:54 PM
  • Your ribbon code specifies that it should only be used for "TabMail". That is only shown for a mail folder, not for a calendar folder.
     
    Use the correct tab id, and if you want your UI shown when in more than 1 module you need to create ribbon XML for each tab you want to work with.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:2f01e817-bc7e-4252-83f0-3c8153ee65e7...

    I am sure GetCustomUI is called, and the code to put ribbon is called too as below:

    *RibbonXml = SysAllocString(
    		_T("<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">")
    		_T("  <ribbon>")
    		_T("    <tabs>")
    	    _T("      <tab idMso=\"TabMail\">")
    		_T("        <group id=\"QuanshiConf\"")
    		_T("               label=\"tool\"")
    		_T("               insertBeforeMso=\"GroupMove\">")
    		_T("          <button id=\"AddQuanshiConf\" ")
    	    _T("                  size=\"large\" ")
    		_T("                  label=\"tool1\"")
    		_T("                  getImage=\"OnGetImage\"")
    		_T("                  onAction=\"OnRibbonBtnReserveConf\"/>")
    		_T("          <dynamicMenu id=\"MoreOptions\"")
    		_T("                       size=\"large\" ")
    		_T("                       label=\"tool2\"") 
    		_T("                       getImage=\"OnGetImageOption\"") 
    		_T("                       getContent=\"OnRibbonBtnMore\"/>")
    		_T("      </group>")
    		_T("   </tab>")
    		_T("  </tabs>")
    		_T(" </ribbon>")
    		_T("</customUI>")
    		);


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Wednesday, July 11, 2012 2:54 PM
  • Hi, Damian,

    TabAppointment doesn't work and finally TabCalendar works.

    Thanks.

    Thursday, July 12, 2012 3:29 AM
  • Hi, Ken,

    I put the dispid as 0xf002, and it always popup error. Below is my code and error show.

    It seems to say that my argument is wrong, but I clearly see in the FolderSwitch function description that this function need no argument.

    SINK_ENTRY_INFO(6, __uuidof(Outlook::ExplorerEvents), 0xf002/*FolderSwitch*/, OnFolderSwitch, &ItemsInfo)
    QSExplorerEvents::DispEventAdvise(m_spExploer, &__uuidof(Outlook::ExplorerEvents)); 

    Thursday, July 12, 2012 3:35 AM
  • I'm not sure, I rarely write or use C++ code, I mostly code in C# or a variant of VB these days.
     
    Have you tried using the full dispid, [id(0x0000f002), rather than a truncated version?

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:cef67ac7-d431-41a8-ab9d-e1e960f9c0ad...

    Hi, Ken,

    I put the dispid as 0xf002, and it always popup error. Below is my code and error show.

    It seems to say that my argument is wrong, but I clearly see in the FolderSwitch function description that this function need no argument.

    SINK_ENTRY_INFO(6, __uuidof(Outlook::ExplorerEvents), 0xf002/*FolderSwitch*/, OnFolderSwitch, &ItemsInfo)
    QSExplorerEvents::DispEventAdvise(m_spExploer, &__uuidof(Outlook::ExplorerEvents)); 


    Ken Slovak MVP - Outlook
    Thursday, July 12, 2012 2:30 PM
  • I tried 0x0000f002,  and it made no difference, the error is still there.

    So confused. I don't know what I missed or What I did wrong........

    Thursday, July 12, 2012 2:37 PM
  • Sorry, that I can't help with. Hopefully someone who does more C++ type stuff will review this thread or the other one you started and jump in. If not, I'll ask someone to take a look at the thread.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "SaraZC" <=?utf-8?B?U2FyYVpD?=> wrote in message news:4b9978ab-d0c2-4abc-b895-179a95d8162e...

    I tried 0x0000f002,  and it made no difference, the error is still there.

    So confused. I don't know what I missed or What I did wrong........


    Ken Slovak MVP - Outlook
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Thursday, July 12, 2012 3:00 PM
  • Thanks.

    I've already worked it out.

    It is failed because the argument of SINK_MAP I put is wrong.

    Thanks very much.

    Friday, July 13, 2012 8:57 AM
  • Hi Damain,

    I still failed to put my ribbon on both calendar or Mail tab. I can only put one of them althought SwitchFolder works well. I put ribbon->Invalidate in ribbon, but it can not call GetCustomUI.

    Do you ever add your ribbon on the main tab of outlook2010?

    Friday, July 13, 2012 9:08 AM
  • i think we already had this conversation - getcustomui is called only once and nothing can make outlook to call it again (short of unloading and loading your add-in). You control visibility of your buttons by callbacks, but of course if you want to place your buttons inside standard tabs and groups you better make sure that they are shown at all in your desired situation. If you want your buttons to appear in main tab despite inbox or calendar view you should add them to both places.
    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Friday, July 13, 2012 10:04 AM
  • Maybe I use a wrong way to put my ribbon on both inbox and calendar view. This is my code below,  and it is wrong because the after xml I insert erase the first xml I wrote. I know it is wrong, but I just don't know how to make it correct.

    STDMETHODIMP CConnect::GetCustomUI(BSTR RibbonID, BSTR * RibbonXml)
    {
    	OutputDebugString(L"OnRibbonLoad-->");
    	CString strRibbonID(RibbonID);
    	if(!RibbonXml)
    	{
    		return E_POINTER;
    	}
             // load xml
    	// for Mail
    	*RibbonXml = SysAllocString(
    		_T("<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">")
    		_T("  <ribbon>")
    		_T("    <tabs>")
    		_T("      <tab idMso=\"TabMail\">")
    		_T("        <group id=\"QuanshiConf\"")
    		_T("               label=\"tool\"")
    		_T("               insertBeforeMso=\"GroupMove\">")
    		_T("          <button id=\"AddQuanshiConf\" ")
    		_T("                  size=\"large\" ")
    		_T("                  label=\"tool1\"")
    		_T("                  getImage=\"OnGetImage\"")
    		_T("                  onAction=\"OnRibbonBtnReserveConf\"/>")
    		_T("          <dynamicMenu id=\"MoreOptions\"")
    		_T("                       size=\"large\" ")
    		_T("                       label=\"tool2\"") 
    		_T("                       getImage=\"OnGetImageOption\"") 
    		_T("                       getContent=\"OnRibbonBtnMore\"/>")
    		_T("      </group>")
    		_T("   </tab>")
    		_T("  </tabs>")
    		_T(" </ribbon>")
    		_T("</customUI>")
    		);
    	// for calendar
    	*RibbonXml = SysAllocString(
    		_T("<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">")
    		_T("  <ribbon>")
    		_T("    <tabs>")
    	    _T("      <tab idMso=\"TabCalendar\">")
    		_T("        <group id=\"QuanshiConf\"")
    		_T("               label=\"tool\"")
    		_T("               insertBeforeMso=\"GroupMove\">")
    		_T("          <button id=\"AddQuanshiConf\" ")
    	    _T("                  size=\"large\" ")
    		_T("                  label=\"tool1\"")
    		_T("                  getImage=\"OnGetImage\"")
    		_T("                  onAction=\"OnRibbonBtnReserveConf\"/>")
    		_T("          <dynamicMenu id=\"MoreOptions\"")
    		_T("                       size=\"large\" ")
    		_T("                       label=\"tool2\"") 
    		_T("                       getImage=\"OnGetImageOption\"") 
    		_T("                       getContent=\"OnRibbonBtnMore\"/>")
    		_T("      </group>")
    		_T("   </tab>")
    		_T("  </tabs>")
    		_T(" </ribbon>")
    		_T("</customUI>")
    }
    		);

     

    Friday, July 13, 2012 11:37 AM
  • 2 things:

    1. check value of ribbonId, you should only return your xml when outlook asks for "Microsoft.Outlook.Explorer"

    2. Combine your 2 strings into one valid xml (remove redundant enclosing tags) so it should be like:

    <customUI>

    <ribbon>

    <tabs>

    <tab>

    </tab>

    <tab>

    ...etc.

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:49 AM
    Friday, July 13, 2012 12:09 PM
  • I tried to put them together, but the result is none of them will be shown in the ribbon, I just don't why.

    *RibbonXml = SysAllocString(
    		_T("<customUI xmlns=\"http://schemas.microsoft.com/office/2006/01/customui\">")
    		_T("  <ribbon>")
    		_T("    <tabs>")
    		_T("      <tab idMso=\"TabMail\">")
    		_T("        <group id=\"QuanshiConf\"")
    		_T("               label=\"tool\"")
    		_T("               insertBeforeMso=\"GroupMove\">")
    		_T("          <button id=\"AddQuanshiConf\" ")
    		_T("                  size=\"large\" ")
    		_T("                  label=\"tool1\"")
    		_T("                  getImage=\"OnGetImage\"")
    		_T("                  onAction=\"OnRibbonBtnReserveConf\"/>")
    		_T("          <dynamicMenu id=\"MoreOptions\"")
    		_T("                       size=\"large\" ")
    		_T("                       label=\"tool2\"") 
    		_T("                       getImage=\"OnGetImageOption\"") 
    		_T("                       getContent=\"OnRibbonBtnMore\"/>")
    		_T("        </group>")
    		_T("      </tab>")
    		_T("      <tab idMso=\"TabCalendar\">")
    		_T("        <group id=\"QuanshiConf\"")
    		_T("               label=\"tool\"")
    		_T("               insertBeforeMso=\"GroupMove\">")
    		_T("          <button id=\"AddQuanshiConf\" ")
    	    _T("                  size=\"large\" ")
    		_T("                  label=\"tool1\"")
    		_T("                  getImage=\"OnGetImage\"")
    		_T("                  onAction=\"OnRibbonBtnReserveConf\"/>")
    		_T("          <dynamicMenu id=\"MoreOptions\"")
    		_T("                       size=\"large\" ")
    		_T("                       label=\"tool2\"") 
    		_T("                       getImage=\"OnGetImageOption\"") 
    		_T("                       getContent=\"OnRibbonBtnMore\"/>")
    		_T("        </group>")
    		_T("       </tab>")
    		_T("  </tabs>")
    		_T(" </ribbon>")
    		_T("</customUI>")
    		);

    Friday, July 13, 2012 1:10 PM
  • first of all - ids cannot be the same so rename them,

    second - groupMove might not exist but this is a minor problem since it will make your buttons appear at the end of whole ribbon

    • Marked as answer by SaraZC Saturday, July 14, 2012 11:50 AM
    Friday, July 13, 2012 1:23 PM
  • Thanks Damian, all the problems have been solved by now, I clearly did less prepare job before I start the work. Thanks for your support and help.

    Saturday, July 14, 2012 11:47 AM