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
Related
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>
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.
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.
I have a command to launch views configured in plugin.xml of an RCP application module as follows:
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="myapp.commandhandler.LaunchView"
id="myapp.command.launchview"
name="Map">
</command>
</extension>
I have configured this command to be shared across a couple of menu extensions like this:
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="myapp.application.menu.showview"
label="Show View">
<command
commandId="myapp.command.launchview"
label="Map"
style="push">
</command>
<command
commandId="myapp.command.launchview"
label="Legend"
style="push">
</command>
</menu>
</menuContribution>
Now I want to pass a command parameter representing each view's ID, similar to what is being done here Eclipse RCP commands.
But when I add these parameter configurations, these menu items disappear from the main menu. Any ideas?
Menu item will disappear from menu if the commandId or commandParameter it is bound to does not exist.
I have written a custom launcher in Eclipse which I can access via the "Run As" and "Debug As" menu options on the toolbar. I also want to be able to launch via the package explorer and via right clicking on the editor of a file to be launched. I followed the tutorial here to add the shortcut but nothing happens, it does not enter my handling code, nor does it complain regarding the configuration of the extension point.
Here is a snippet from my plugin.xml
<extension point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
id = "org.mylauncher.launchCalcShortcut"
class = "org.mylauncher.LaunchCalcShortcut"
description="Execute calculations"
icon="icons/launch_16_16.png"
label="Calculate"
modes="run, debug" >
<configurationType id="org.mylauncher.launchCalc"/>
</shortcut>
I have also played with removing the (optional) icon attribute, and have separately validated the path of the icon.
I've been modifying this configuration for hours now with no good result and it is impossible to debug as it is not running in my own code at all.
Thanks.
It seems that the correct answer to this problem is to specify a contextual launch shortcut. Here is my working configuration:
<extension
point="org.eclipse.debug.ui.launchShortcuts">
<shortcut
class="com.xxxx.CalcLaunchShortcut"
icon="calc.png"
id="com.xxxx.CalcLaunchShortcut"
label="Calc"
modes="run, debug">
<contextualLaunch>
<contextLabel mode="run" label="Run Calculator" />
<contextLabel mode="debug" label="Debug Calculator" />
<enablement >
<with variable="selection">
<count value="1"/>
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
<and>
<test property="org.eclipse.core.resources.name" value="*.calc"/>
</and>
</adapt>
</iterate>
</with>
</enablement>
</contextualLaunch>
</shortcut>