How to display two controls aligned horizontally in a custom Ribbon XML - vsto

In a group of a custom tab of a Ribon XML of a custom VSTO WORD AddIn, I need to display an editBox aligned horizontally inline with a checkBox. How can I achieve that? Following displays both the controls aligned vertically one after the other:
<tab idMso="TabAddIns">
<group id="ContentGroup" label="Content">
<editBox id="editBoxID" label="Insert Text"
screentip="Text" onAction="getText"/>
<checkBox id="checkBoxID" label="Enable" />
</group>
</tab>

Use a box, with a horizontal boxStyle.
<group id="groupid" label="Content">
<box id="ContentGroup" boxStyle="horizontal">
<editBox id="editBoxID" label="Insert Text" />
<checkBox id="checkBoxID" label="Enable" />
</box>
</group>

Related

How to add inbuilt tool of Powerpoint in Custom UI Editor Customized Tab

As I was creating customized tab which will help me all the tool I use in single tab with the help of "Custom UI" in that I can add which i have scripted, but not getting how to add the inbuilt tool of powerpoint for example "Font Color Picker" i want to add what should I do.
Below are the script
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="customTab" label="GEPper">
<group id="TextTools" label="Text Tools">
<button id="FontSize" label=" " image="a4" size="normal" onAction="FontSize" screentip="Font Size 10" supertip=" "/>
<button id="FontSize12" label=" " image="a3" size="normal" onAction="FontSize12" screentip="Font Size 12" supertip=" "/>
<button id="FontSize14" label=" " image="a2" size="normal" onAction="FontSize14" screentip="Font Size 14" supertip=" "/>
<button id="FontSize16" label=" " image="a1" size="normal" onAction="FontSize16" screentip="Font Size 16" supertip=" "/>
<button id="FontColorBlack" label=" " image="black" size="normal" onAction="FontColorBlack" screentip="Font Color Black" supertip=" "/>
<button id="FontColorWhite" label=" " image="white" size="normal" onAction="FontColorWhite" screentip="Font Color White" supertip=" "/>
<button id="Bullet" label=" " image="bullet" size="normal" onAction="Bullet" screentip="Bullet Color Black" supertip=" "/>
<button idMso="FontColorPicker"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
It would be great help if anyone can help me out
In a ribbon mod, the XML for a built-in gallery looks like this:
<gallery
idMso="FontColorPicker"
showImage="true"
showLabel="false"/>
To find other idMso identifiers, you need to reference a set of Excel spreadsheets published by Microsoft. Here's the link for the 2016 (also applies to 2019) files: Office 2016 Help Files: Office Fluent User Interface Control Identifiers
There is one workbook for PowerPoint. Search the first column.

VSTO Addin same buttons multiple tab

Working on the VSTO Add-in for Outlook. Is there anyway to avoid duplicating the whole ribbon XML code if I just want the same buttons to appear under two different tab/view (TabCalendar and TabMail)
My ribbon code is the following:
<ribbon>
<tabs>
<tab idMso="TabMail">
<button id="ID1" label="XxX" onAction="OnTextButton" image="myImg1" size="large" getVisible="GetVisible"/>
<button id="ID2" label="XxX" onAction="OnTextButton" image="myImg2" size="large" getVisible="GetVisible"/>
...
</tab>
<tab idMso="TabCalendar">
<button id="SameThanID1" label="XxX" onAction="OnTextButton" image="myImg1" size="large" getVisible="GetVisible"/>
<button id="SameThanID2" label="XxX" onAction="OnTextButton" image="myImg2" size="large" getVisible="GetVisible"/>
...
</tab>
</tabs>
</ribon>
What I would love to to is:
<ribbon>
<tabs>
<tab idMso="TabMail" OR "TabCalendar">
<button id="ID1" label="XxX" onAction="OnTextButton" image="myImg1" size="large" getVisible="GetVisible"/>
<button id="ID2" label="XxX" onAction="OnTextButton" image="myImg2" size="large" getVisible="GetVisible"/>
...
</tab>
</tabs>
</ribon>
It is really annoying as the button needs to be unique and I therefore have to duplicate the same logic. I read this post which is not really encouraging. Is there any option?
The Fluent UI (aka Ribbon UI) doesn't allow to combine built-in tabs markup and place the ribbon XML into a single place. You need to specify (repeat) the markup for each built-in tab separately. Read more about the ribbon UI in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

Excel Context Menu Not Showing

I am using the "Custom UI Editor For Microsoft Office". I have added an "Office 2007 Custom UI Part" which creates the "customui.xml" file for me. It currently has the following code which adds my "Zoom Cell" button to the developer tab.
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso="TabDeveloper" >
<group id="customGroup1" label="Zoom" insertAfterMso="GroupModify">
<button id="customButton1" label="Zoom Cell" size="large" onAction="ZoomCell" imageMso="ZoomPrintPreviewExcel" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
What I am trying to do is add the same button basically to the context menu for right-clicking on a cell; however, it is not working for me. If I modify the code even the button from the above code gets removed. Here is what I have tried. I am pretty sure that there is something weird in my xml code; I just can't find it.
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso="TabDeveloper" >
<group id="customGroup1" label="Zoom" insertAfterMso="GroupModify">
<button id="customButton1" label="Zoom Cell" size="large" onAction="ZoomCell" imageMso="ZoomPrintPreviewExcel" />
</group>
</tab>
</tabs>
</ribbon>
<contextMenus>
<contextMenu idMso="ContextMenuCell">
<button id="MyButton" label="Zoom Cell" onAction="ZoomCell" imageMso="ZoomPrintPreviewExcel" insertBeforeMso="Cut" />
</contextMenu>
</contextMenus>
</customUI>
When I put your code in the CustomUI Editor and try to validate it, I get an error that "contextMenus" is not supported element in the CustomUI namespace, followed by a list of expected/allowable elements:
Allowable elements are:
qat
officeMenu
contextualTabs
It seems from THIS LINK (which is for Outlook, but I believe the approach would be same/similar for Excel/etc.) that context Menus are manipulated through VBA events in Office 2007.
I think that RibbonUI manipulation of context menus was not introduced until 2010.

Add Event to UI button click

I have created a custom ribbon in Microsoft Word but I am having issues attaching events to the buttons found in a ribbon. Below is my code:
UI XML:
<mso:cmd app="Word" dt="1" />
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="true" >
<tabs>
<tab id="CustomTab" label="MyTasks" >
<group id="Group1" label="Details Labels">
<menu id="Menu1" label="Details" size="large">
<menu id="Menu21" label="Dates">
<button id="my_date" onAction="foo_eventhandler" label="Some Date" />
</menu>
</menu>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I then have the following VBA code in Modules/NewMacros VBA code:
Sub foo_eventhandler(control As IRibbonControl)
End Sub
NOTE:
I import the XML by opening Word-->going to File-->Options-->Customize Ribbon-->Import/Export. I then select my XML file and import it.
When this code is run, though, I get the error "Argument Not Optional". If I run the same code without the "control As IRibbonControl" it's fine but I need to be able to get the Sender object. Anyone have any suggestions?
jason
I think you are running into problems because you are importing the XML code via Options -> Customize Ribbon ->Import/Export. This method is really for general users who wish, for example, to never see the Page Layout tab and have it hidden. They can export their custom ribbon and import it onto new machines for the same layout.
For developers a better method is use the most excellent CustomUIEditor for Word and Excel. http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2009/08/07/7293.aspx
The steps you need to take are to create your normal macro enabled Word template (the .dotm) file and save it. Then open that file up in the CustomUIEditor and paste you XML (minus the first line). I've expanded your XML code with another button and I've added the tag to the XML so the VBA knows which button is being pressed.
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon startFromScratch="false" >
<tabs>
<tab id="CustomTab" label="MyTasks" >
<group id="Group1" label="Details Labels">
<menu id="Menu1" label="Details" size="large">
<menu id="Menu21" label="Dates">
<button id="my_date_1" onAction="foo_eventhandler" label="Some Date" tag="Date1" />
<button id="my_date_2" onAction="foo_eventhandler" label="Some Other Date" tag="Date2" />
</menu>
</menu>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I generally put my Ribbon code in a Ribbon module. In your callback code you just need to use the .Tag property of the inputted control variable to know which button is pressed which you'll see corresponds to the tag in the XML. ie:
Sub foo_eventhandler(control As IRibbonControl)
MsgBox "Hooray! for " & control.Tag
End Sub

XAML Context Menu not closing

I've got a "popup" context menu on a list box, and there are two behaviors that would seem "out-of-the-box" but I am having a tough time getting the XAML ContextMenu to behave the way I would expect...
One is that, when I pick a sub-menu (e.g. "One" or "Two"), the initial menu continues to stay open (e.g. "Menu" does not go away once I've made a selection).
Second is that the menu margins seem odd. Left justifying Horizontally does not seem to make the main menu (e.g. "Menu") left justify... I can work around this by tweaking the margin - but thats painful for dynamic text..
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<StackPanel>
<ListView>
<ListView.ContextMenu>
<!-- StaysOpen="False" -->
<ContextMenu>
<!-- Background="Transparent" Margin="-8,0,-8,0" -->
<Menu>
<!-- StaysOpenOnClick="False" -->
<MenuItem Header="Menu">
<MenuItem Header="One" />
<MenuItem Header="Two" />
</MenuItem>
</Menu>
</ContextMenu>
</ListView.ContextMenu>
<ListViewItem Content="Red" />
<ListViewItem Content="Orange" />
<ListViewItem Content="Black" />
<ListViewItem Content="Blue" />
<ListViewItem Content="Green" />
</ListView>
</StackPanel>
</Page>
Any thoughts on how to make the Main menu of this popup behave?
Thanks in advance,
T
Try this:
<ContextMenu>
<MenuItem Header="Menu">
<MenuItem Header="One" />
<MenuItem Header="Two" />
</MenuItem>
</ContextMenu>
you are not supposed to have a menu inside a context menu.
you should put menuitem directly.