Using this Outlook 2013, I develop an addin in C#. My ribbon.xml looks like:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<contextMenus>
<!-- Move mail to -->
<contextMenu idMso="ContextMenuMailItem">
<button id="MoveMailTo_CM"
imageMso="CopyToFolder"
insertBeforeMso="Copy"
getLabel="MoveMailTo_GetLabel"
getVisible="MoveMailTo_GetVisible"
onAction="MoveMailTo_OnAction"/>
</contextMenu>
<!-- Manage holiday request -->
<contextMenu idMso="ContextMenuMailItem">
<button id="ManageHolidayRequest_CM"
imageMso="CopyToPersonalCalendar"
insertBeforeMso="Copy"
label="Copy to Calendar"
getVisible="ManageHolidayRequest_GetVisible"
onAction="ManageHolidayRequest_OnAction" />
</contextMenu>
</contextMenus>
</customUI>
When I launch my addin using Visual Studio and I right-click on an email item, only the first "getVisible" is called (the MoveMailTo_GetVisible) but not the other one.
If i switch both menu, only ManageHolidayRequest_GetVisible is called.
Can't we specify two different function in that case? Any workaround ?
Best regards,
Answer was : I had two <contextMenu idMso="ContextMenuMailItem"> (so for the same Mso). Just merged both button in context Menu and worked.
Related
I am developing a Microsoft Excel Addin.
I need to add a button on context menu (right click) on cell selected text. I have found the ContextMenuCell idMso but this works only on whole cell right click.
Here is my ribbon's xml:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
</ribbon>
<contextMenus>
<contextMenu idMso="ContextMenuCell">
<button id="TranslateTextButton" label="Test Label" onAction="OnRibbonClick" getImage="GetIcon"/>
</contextMenu>
</contextMenus>
</customUI>
I wonder if exists something like ContextMenuCell for cell's text and not whole cell. Thank you in advance!
After many searches I found ContextMenuFormulaBar which enables right click on formula bar and also in a cells inner (text etc.).
I'm working with Outlook VSTO Add In and first I have added a Button(ribbon) to the TabMail and after that I need a custom context menu item on right click any Inbox item, So I have added another Ribbon, but inside CreateRibbonExtensibilityObject() I can return only one Ribbon.
Inside ThisAddIn.cs
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
return new Ribbon2();
}
I tried with some old unclear solution like below adding namespace, but it's not working,maybe they are for merging two tab and group but not for two different type ribbon.
ContextMenuRibbon
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui"
onLoad="Ribbon_Load" xmlns:x="MySpace.Outlook">
<contextMenus>
<contextMenu idMso="ContextMenuMailItem">
<button
id="MyContextMenuMailItem" label="ContextMenuMailItem"
idQ="MyRibbons"/>
</contextMenu>
</contextMenus>
</customUI>
How can I use both Ribbon in same Add In?
You must provide a single XML string with both elements specified in it.
I'm writing an outlook Add-In in VS2017. I need a context menu to appear when 1 or more calendar events are selected. I can get a context menu to appear when a single calendar event is selected with the following XML:
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui" loadImage="GetImage">
<contextMenus>
<contextMenu idMso="ContextMenuCalendarItem">
<button id="MyContextMenuCalendarItem"
label="Copy To Google Calendar"
image="Google_Calendar_Logo.png"
onAction="CopyToGoogleCalendar_Click"/>
</contextMenu>
</contextMenus>
</customUI>
If I use the idMso "ContextMenuMultipleItems", the context menu will appear when multiple of any type (email, calendar, etc.) is selected. I can not figure out the correct idMso for context menu with multiple calendar events selected.
Any help would be greatly appreciated.
Turns out that using the "ContextMenuMultipleItems" idMso works with the added "getVisible" method. My XML now looks like:
<?xml version="1.0" encoding="utf-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui" loadImage="GetImage">
<contextMenus>
<contextMenu idMso="ContextMenuCalendarItem">
<button id="MyContextMenuCalendarItem"
label="Copy To Google Calendar"
image="Google_Calendar_Logo.png"
onAction="CopyToGoogleCalendar_Click"/>
</contextMenu>
<contextMenu idMso="ContextMenuMultipleItems">
<button id="MyContextMenuMultipleItems"
label="Copy To Google Calendar"
image="Google_Calendar_Logo.png"
getVisible="ContextMenuMultipleItems_IsVisible"
onAction="CopyToGoogleCalendar_Click"/>
</contextMenu>
</contextMenus>
</customUI>
and the ContextMenuMultipleItems_IsVisible looks like:
public bool ContextMenuMultipleItems_IsVisible(Office.IRibbonControl control)
{
if (control.Context is Outlook.Selection)
{
Outlook.Selection selection = control.Context as Outlook.Selection;
if (selection[1] is Outlook.AppointmentItem)
return true;
}
return false;
}
I'm trying to add a new element to the Visual Studio 2017 Context Menu. I managed to add an element to the TOOLS menu with the following code:
<Button guid="guidRandomCommandPackageCmdSet" id="RandomCommandId" priority="0x0100" type="Button">
<Parent guid="guidSHLMainMenu" id="IDG_VS_TOOLS_EXT_TOOLS" />
<Icon guid="exclamationIcon" id="exclamationIcon1" />
<Strings>
<ButtonText>Random Text</ButtonText>
</Strings>
</Button>
which is registered in
<GuidSymbol name="guidRandomCommandPackageCmdSet" value="{47122772-c66f-48f3-b10b-dbbb66da120d}">
.
.
<IDSymbol name="RandomCommandId" value="0x0100" />
</GuidSymbol>
I tried to follow a similar fashion, so I defined a new Button in Buttons:
<Button guid="guidRandomCommandPackageCmdSet" id="ToDoList" priority="0x0100" type="Button">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN"/>
<Icon guid="exclamationIcon" id="exclamationIcon1" />
<Strings>
<ButtonText>Add TODO list</ButtonText>
</Strings>
</Button>with the ID symbol
with the ID registerd in GuidSymbols
<IDSymbol name="ToDoList" value="0x106" />
But the button does not show up in the context menu, when I run the project. I tried to follow the suggestions of VSIX: Adding a Menu Item to the Visual Studio Editor Context Menu but none of the suggestions seems to work for me.
I never tried to create a VS add-on before, so I welcome any suggestions. Is it possible that the method changed in VS 2017?
Eventually, I managed to get it working. It seems that while for MENU items that show up either as a separate menu or belonging to a menu like TOOLS, it is enough to have only a Button with the parent set to the appropriate constant menu element string as defined at GUIDs and IDs of Visual Studio Menus.
For ContextMenu elements, however, I needed to have an element in Groups:
<Group guid="guidRandomCommandPackageCmdSet" id="MyMenuGroup" priority="0x0600">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_CODEWIN" />
</Group>
This has the ContextMenu as its Parent. Then, I created a CustomCommand that auto-generates a Button with it and I modified this Button to have the Group element as itsParent:
`
Add TODO list
This is the result with the added button hovered over:
I am developing a Power Point Add-in (Using C#) in which I have to add a Custom Menu Entry in the "File" Menu.
I followed all the steps in http://msdn.microsoft.com/en-us/library/bb608602(v=vs.100).aspx
but my menu is not showing up in Powerpoint.
Do I need to anything extra here ?
You must check i would my add-in to lad the host
Link of full sample : http://csharpmentor.blogspot.fr/2009/05/how-to-create-powerpoint-add-in-in-cnet.html
#Nilzor, I found the Solution, It is called Backstage view
We need to add the in the XML to make it work
<?xml version="1.0" encoding="utf-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<backstage>
<tab id="MyBackstageTab"
label="My Tab"
getVisible="MyBackstageTab_GetVisible">
</tab>
</backstage>
</customUI>