VSTO Addin same buttons multiple tab - vsto

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)

Related

VBA Word Custom Ribbon does not effect Macros

I've written a few subroutines in VBA to do some things in Word that I want it to do. It works as intended. However, when I created a custom ribbon for it, using the Office RibbonX Editor and generated callbacks, nothing happens when the associated button is pressed. Here is the xml schema for the ribbon:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false" >
<tabs>
<tab id="Ribbon1" label="Custom Ribbon">
<group id="Group_1" label="Common" autoScale="true">
<button id="btn1" label="DoThis" imageMso="AppointmentColor10" onAction="RibbonControl.DoThis" visible="true"/>
<button id="btn2" label="DoThis1" imageMso="BlackAndWhiteWhite" onAction="RibbonControl.DoThis1" visible="true"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Callbacks are generated like this:
'Callback for btn1 onAction
Sub DoThis(control As IRibbonControl)
End Sub
'Callback for btn2 onAction
Sub DoThis1(control As IRibbonControl)
End Sub
I have tried different modification of the >onAction< attribute, but between getting VBA errors and buttons not working, this is the point I'm stuck in.
I'd appreciate any tips on how to solve it.
In my working Ribbon XML I am not using a module name, just calling the method directly. So your XML code should look like this:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false" >
<tabs>
<tab id="Ribbon1" label="Custom Ribbon">
<group id="Group_1" label="Common" autoScale="true">
<button id="btn1" label="DoThis" imageMso="AppointmentColor10" onAction="DoThis" visible="true"/>
<button id="btn2" label="DoThis1" imageMso="BlackAndWhiteWhite" onAction="DoThis1" visible="true"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
For these methods to be reachable from the Ribbon some things must be true:
The code must exist in a regular Module. Not a class module, form, or any other object. Make a module called "RibbonActions" or something and put them all there.
The methods must be public, your subs are implicitly public so that should work but I like to add the Public keyword just to be explicit about it.
The signature must match the event, which yours does appear to fit the pattern.

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

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>

Generate PDF with custom structure using doxygen

Before I'm going into the details, short brief first:
I'm trying to customize the pdf document structure generated by doxygen. I'm already doing this for html and chm output, but for pdf it does not work.
My primary question is, is this restriction by design or am i missing something?
If this is by design, is there any other way I could go starting from doxygen, resulting in a customized pdf document?
Here are the details:
We are using doxygen to generate sourcecode documentation for a C API, which is also wrapped using C++, C# and Java.
We want to document all these languages in one single document, but structure it by language. In order to achieve this we customized the document structure using a DoxygenLayout.xml file in the following way:
First come a few pages of descriptive text, that applies to all
languages, we call this part "user manual".
Second comes the API documentation, which is structured into the different languages.
In other words, we completely disable the standard structure and define our own.
The layout definition looks pretty much like in this simplified example:
<navindex>
<tab type="mainpage" visible="yes" title="My Project"/>
<tab type="pages" visible="no" title="" intro=""/>
<tab type="modules" visible="no" title="" intro=""/>
<tab type="namespaces" visible="no" title="">
<tab type="namespacelist" visible="no" title="" intro=""/>
<tab type="namespacemembers" visible="no" title="" intro=""/>
</tab>
<tab type="classes" visible="no" title="">
<tab type="classlist" visible="no" title="" intro=""/>
<tab type="classindex" visible="no" title=""/>
<tab type="hierarchy" visible="no" title="" intro=""/>
<tab type="classmembers" visible="no" title="" intro=""/>
</tab>
<tab type="files" visible="no" title="">
<tab type="filelist" visible="no" title="" intro=""/>
<tab type="globals" visible="no" title="" intro=""/>
</tab>
<tab type="examples" visible="no" title="" intro=""/>
<tab type="usergroup" title="User Manual">
<tab type="user" title="Page 1" url="#ref page1"/>
</tab>
<tab type="usergroup" title="API documentation">
<tab type="usergoup" title="C">
<tab type="user" title="SomeFunction" url="#ref SomeFunction" />
<tab type="user" title="AnotherFunction" url="#ref AnotherFunction" />
</tab>
<tab type="usergoup" title="C#">
<tab type="usergroup" title="A.Class1">
<tab type="user" title="SomeFunction" url="#ref A.Class1.SomeFunction" />
</tab>
<tab type="usergroup" title="B.Class2">
<tab type="user" title="AnotherFunction" url="#ref B.Class2.AnotherFunction" />
</tab>
</tab>
<tab type="usergoup" title="Java">
<tab type="usergroup" title="com.xyz.A.Class1">
<tab type="user" title="SomeFunction" url="#ref com.xyz.A.Class1.SomeFunction" />
</tab>
<tab type="usergroup" title="com.xyz.B.Class2">
<tab type="user" title="AnotherFunction" url="#ref com.xyz.B.Class2.AnotherFunction" />
</tab>
</tab>
</tab>
</navindex>
This works perfectly fine for chm and html output, but unfortunatly seems to be completely ignored for the latex and docbook output, which could be used to generate pdf.
The documentation for the layoutfile implies that it should work independently from the used output:
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
# by doxygen. The layout file controls the global structure of the generated
# output files in an output format independent way. To create the layout file
# that represents doxygen's defaults, run doxygen with the -l option. You can
# optionally specify a file name after the option, if omitted DoxygenLayout.xml
# will be used as the name of the layout file.
#
# Note that if you run doxygen from a directory containing a file called
# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
# tag is left empty.
LAYOUT_FILE = "DoxygenLayout.xml"
Doxygen produces a number of files in the latex directory, in this case the most notable are:
refman.tex, with a number of settings and the include of the different chapters, probably most suitable for the things you want.
doxygen.sty with a the settings doxygen uses. One can modify this file (not really advise), one can also add extra style sheets by means of the configuration tag LATEX_EXTRA_STYLESHEET where one overrules (e.g. by renew commands) default commands.
Noteworthy are also settings like LATEX_HEADER, LATEX_FOOTER,EXTRA_PACKAGES`, see the documentation (chapter Configuration in http://www.doxygen.nl/manual/) for these and more possibilities.
For docbook output the current version, version 1.8.15, might work a bit better but there is no special "stylesheett" for docbook.

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