Debugging vsto ribbon callbacks - vsto

I have a VSTO Outlook ribbon (context menu), which works as expected:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<contextMenus>
<contextMenu idMso="ContextMenuMailItem">
<button id="DoThis"
label="Label"
onAction="DoThis"
getVisible="GetVisible"/>
</contextMenu>
</customUI>
However, if I have a getLabel attribute, then the context menu does not show up at all anymore. I guess I must be screwing something up, but there is no indication what; no log, no exception, nothing. Furthermore, I can't find anywhere that documents what the definition of each callback should be. I just tried the obvious, that getLabel should return a string, but it does not seem to work. getVisible works just fine (returning a bool).
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<contextMenus>
<contextMenu idMso="ContextMenuMailItem">
<button id="DoThis"
label="Label"
onAction="DoThis"
getVisible="GetVisible"
getLabel="GetLabelMoveToReviewFolderMultiple"/>
</contextMenu>
</customUI>
and the code behind (other methods not shown):
[ComVisible(true)]
public class ContextMenu : Office.IRibbonExtensibility
{
public string GetLabelMoveToReviewFolderMultiple(Office.IRibbonControl control)
{
return "Custom Label";
}
}

Do not use both label and getLabel. Also, enable addin errors in File | Options | Advanced | Developer to see all ribbon XML errors.

Well, while writing the question, I tried removing the label attribute for the context menu using getLabel, and that does resolve the issue; context menu works fine after that. I (initially) thought it might make sense to keep label as a default.
The documentation explains what is mutually exclusive.

Related

Vistual Studio VSTO Outlook Add-in: Add custom group to specific Tab

I've been able to create an addin for outlook and have added a Ribbon (Visual Designer) and set a custom tab and a few controls. The thing is i need it to be on a specific view.
In this case, i need it to be on the meeeting and appointment views.
First i click on the Calendars view on outlook:
Then, whenever i click on any appointment or meeting, and i need to have a custom icon on that place:
Is this possible? I've tried with some ControlId Settings but none seems to get the job done.
Thanks in advance.
Of course. Your ribbon XML must specify the appropriate built-in tab (see TabAppointment below) and the built-in group (see insertBeforeMso="GroupClipboard" below)
<?xml version="1.0" encoding="utf-16" standalone="no"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OnLoad">
<ribbon>
<tabs>
<tab idMso="TabAppointment">
<group id="id1" label="Infor CRM" visible="1" insertBeforeMso="GroupClipboard" getImage="GetImage">
<toggleButton id="id2" size="large" getLabel="OnGetLabel" getImage="GetImage" getPressed="OnGetButtonPressed" screentip="tip" supertip="supertip" onAction="OnToggleButtonClick" getEnabled="GetEnabled"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>

Eclipse plug-in: nameFilter of propertyPages takes a strange effect

I use Eclipse SDK Mars.1(4.5.1). I create a propertyPages plug-in.
In plugin.xml:
If I change value of “nameFilter” to “.txt”, then only when I select .txt file, the propertyPage item can appear in left of the properties dialog;
If I change value of “nameFilter” to “.java” or “.xml” or even “.*”, then still only when I select .txt file, the propertyPage item can appear.
Here is my plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.propertyPages">
<page
id="com.def.btp_property_3.properties.BTPPropertyPage"
name="BTP Page"
class="com.def.btp_property_3.properties.BTPPropertyPage"
nameFilter="*.java">
<enabledWhen>
<instanceof
value="org.eclipse.core.resources.IFile">
</instanceof>
</enabledWhen>
</page>
</extension>
</plugin>
Can anyone tell me the reason and give me a solution.
For the enableWhen use:
<enabledWhen>
<or>
<instanceof
value="org.eclipse.core.resources.IFile">
</instanceof>
<adapt
type="org.eclipse.core.resources.IFile">
</adapt>
</or>
</enabledWhen>
User interface elements in views are often not instances of IFile, instead they are some other object which can be 'adapted' to IFile. This enabledWhen deals with this case.

Is there a way to disable CommandBar Controls in Powerpoint VBA?

I have a PPT Add-In which may fail if a certain ViewType is not maintained.
I do not see any PPTEvent which I could trap the change and prevent it (although, if this is possible, please advise!). So I have been playing with the Ribbon/CommandBars attempting to disable or hide certain controls pertaining to the ViewType.
I have identified the controls by Id and I attempt to set their .Visible property to False, or alternatively, to .Enabled = False, but neither seems to have any affect. The controls are still visible, and clicking on them still executes.
This example I would try to disable the Slide Sorter control. This prevents VBE from Execute the Button, but it does not disable the button's action as far as the user might still click it, it still executes.
Sub DisableViewChange()
Dim cBar As CommandBar
Dim ctrl As CommandBarControl
Set cBar = CommandBars("View")
Set ctrl = cBar.FindControl(Id:=738)
ctrl.Visible = True
ctrl.Enabled = False
Set btn = ctrl
btn.Execute
Set cBar = Nothing
Set btn = Nothing
Set ctrl = Nothing
End Sub
Update to include pics of the elements I would like to disable/hide/remove:
You can definitely modify the XML of a specific document to remove certain ribbon elements from the ribbon - I have done a huge amount of this. You should investigate using the Custom UI Editor which will open up the document and allow you to modify the XML of your selected ribbon groups by using the Visible = False modifier. Then, you should be able to save the Add-In and when it's loaded into memory it will hide the parts you've specified, preventing your crash.
This was useful for me a while ago:
http://gregmaxey.mvps.org/word_tip_pages/customize_ribbon_main.html
There are Microsoft XML Schemas for each of the Office applications (which I can't find now - but definitely exists).
I hope that's some help.
Red's suggestion above was very helpful. With some (errr... a lot) of trial and error, I was able to make some tweaks to the Ribbon. I present this answer in hopes that my trial and error will be useful to someone else who is equally unfamiliar with XML:
I disable several commands that I was looking to disable, that was relatively easy:
<commands>
<command idMso="ViewSlideSorterView" enabled="false"/>
<command idMso="ViewNotesPageView" enabled="false"/>
<command idMso="ViewSlideShowReadingView" enabled="false"/>
<command idMso="ViewSlideMasterView" enabled="false"/>
<command idMso="ViewHandoutMasterView" enabled="false"/>
<command idMso="ViewNotesMasterView" enabled="false"/>
<command idMso="WindowNew" enabled="false"/>
</commands>
Since I am fussing with the XML, I decide also to migrate my add-in's commands from a legacy CommandBar (under the Add-Ins Tab group) to a custom ribbon tab, so this XML also contains a working example of a new Tab, which consists of a Group, a menu, and a few buttons in that menu.
Here is the validated XML including the disabled commands and the custom tab menu:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<commands>
<command idMso="ViewSlideSorterView" enabled="false"/>
<command idMso="ViewNotesPageView" enabled="false"/>
<command idMso="ViewSlideShowReadingView" enabled="false"/>
<command idMso="ViewSlideMasterView" enabled="false"/>
<command idMso="ViewHandoutMasterView" enabled="false"/>
<command idMso="ViewNotesMasterView" enabled="false"/>
<command idMso="WindowNew" enabled="false"/>
</commands>
<ribbon startFromScratch="false">
<tabs>
<tab idMso="TabView">
<group idMso="GroupPresentationViews" visible="true"/>
<group idMso="GroupMasterViews" visible="true"/>
</tab>
<tab id="MyNewTab" label="My Tab Label">
<group id="MyGroupMain" label="My Group Label">
<menu id="MyMenu" imageMso="HappyFace" size="large">
<button id="MyLaunchButton" label="Launch Tiger" onAction="macro1" />
<button id="MyInfoButton" label="Info" onAction="macro2" />
<button id="MyVersionButton" label="Version" onAction="macro3" />
<button id="MyHelpButton" label="Help" onAction="macro4" />
</menu>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I have not hooked my subroutines/macros in to these buttons yet, but that should not be terribly difficult.
I would not have been able to get through this without stumbling upon this link, which contains a batch of Excel files (for each Application) listing all of the menu items by type, id, relationship to other items, etc.
http://www.microsoft.com/en-us/download/details.aspx?id=6627

Word Ribbon VBA stops working when copied to Startup Folder

I have developed a small Ribbon for our company, which works fine when launched from it's dotm file - but I have problemswhen I try to store it in the Startup folder.
I have stored it as a dotm file and copied it to the startup folder. The ribbons are perfectly visible when launching word, but every click on a menu item causes a runtime error 5941 :(
the XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="RibbonControl.Onload">
<ribbon>
<tabs>
<tab id="Best" label="My Tools">
<group id="FBCATI" visible="true" label="Fragebogen">
<dropDown id="FBC1" label="CATI"
getItemCount="RibbonControl.GetItemCount"
getItemLabel="RibbonControl.GetItemLabel"
getSelectedItemIndex="RibbonControl.GetSelectedItemIndex"
onAction="RibbonControl.MyCatiMacro"
/>
<dropDown id="FBW1" label="WEB"
getItemCount="RibbonControl.GetItemCount"
getItemLabel="RibbonControl.GetItemLabel"
getSelectedItemIndex="RibbonControl.GetSelectedItemIndex"
onAction="RibbonControl.MyWebMacro"
/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
some code behind.
Sub Onload(ribbon As IRibbonUI)
'Creates a ribbon instance for use in this project
Set myRibbon = ribbon
End Sub
'Callback for DropDown GetItemCount
Sub GetItemCount(ByVal control As IRibbonControl, ByRef count)
'Tell the ribbon to show 4 items in the dropdown
count = 6
End Sub
Put your file under %appdata%\Microsoft\Templates\
And create another .dotm file which should be under StartUp folder and which would attach your file with ribbon.

background image somehow covers up all the controls adobe flash builder 4.6

I created a skin using an image as background.
When my View imported the skin as skinClass, it covers up all the other controls.
How do i make all the controls display above the skin?
This is my Skin code called Background.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<!-- host component -->
<fx:Metadata>
[HostComponent("spark.components.supportClasses.SkinnableComponent")]
</fx:Metadata>
<s:Image source="assets/Sunflower.gif" smooth="true" left="0" right="0" top="0" bottom="0">
</s:Image>
<s:states>
<s:State name="normal" />
</s:states>
</s:Skin>
This is the main view under default package
<?xml version="1.0" encoding="utf-8"?>
<s:TabbedViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160"
skinClass="BackgroundImage"
>
<s:ViewNavigator label="Add" width="100%" height="100%" firstView="views.AddView"/>
<s:ViewNavigator label="List" width="100%" height="100%" firstView="views.ListView"/>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
</s:TabbedViewNavigatorApplication>
It looks like your Z index should be adjusted for the controls.
You can change your z-index like this:
parent.setChildIndex(childObject, i)
So for example if you want your controls to always be on front you need:
myControls.parent.setChildIndex(myControls, myControls.parent.numChildren -1)
Hope this helps you, even tho it's hard to answer it without any code...