I have a .net addin for Excel. The addin creates the Ribbon UI for Excel 2007 and re-purposes some existing commands such as Cut, Copy, Paste, Sort etc.
For Cut, Copy and Paste I am just overriding their OnAction value to call my own procedure when the buttons are clicked. But for Sort, Sort Asc and Sort Desc commands the case is a little different. When either of the Sort, Sort Asc or Sort Desc buttons are clicked, I want to get notified and then call the default functionality. This was possible in Excel 2003 commandsbars by calling the Execute() method on the CommandBarControl.
In Excel 2007, there is a ExecuteMso() method to programmatically click a ribbon element but when the OnAction is overridden, this ExecuteMso() method just executes my own procedure and not the default functionality of that button.
So I thought that I will HIDE the Sort buttons in the "Editing" group in Home tab and add my own Sort, Sort Asc and Sort Desc buttons to it. The buttons will call into my procedure first from where I will call the default behavior.
Now the problem is that I am unable to change/hide the Editing group (idMso="GroupEditing"). Is this built-in group not editable? I can however HIDE the Clipboard and other groups(but can't add buttons to them).
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso="TabHome">
<group idMso="GroupEditing" visible="false" />
</tab>
</tabs>
</ribbon>
</customUI>
I think the idMso is incorrect in relation to hiding the Editing group.
idMso="GroupEditingExcel"
Related
I have a custom XML ribbon tab in a VSTO Excel Add-in. The XML for the custom ribbon tab is below.
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab idMso="TabAddIns" label="EMP">
<group id="EMPForms" label="Measurement Study">
<button id="EMPStudy"
label="EMP Study"
screentip="EMP Data"
supertip="Measurement Study Data"
onAction="OnEMPData"/>
<button id="StudySetup"
label="Study Setup"
screentip="Setup"
supertip="Measurement Study Setup"
onAction="OnStudySetup"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
There is only one group specified in the XML.
When I run the Add-in, I get two groups. The first is "Custom Toolbars". The second is "Measurement Study". The "Custom Toolbars" is not specified in the XML below.
Is there a way to prevent groups or controls from other ribbon tabs from appearing on a custom ribbon tab?
Try to check out other add-ins and Excel documents (they may contain a custom ribbon UI).
There is no way to hide controls or groups on a custom ribbon tab if you don't know their IDs. The best what you can do is to use the startFromScratch attribute which allows hiding the built-in ribbon controls. Read more about the Fluent UI (aka 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)
The source of the "Custom Toolbar" group on my custom ribbon is the "Team Foundations Add-in".
Below are the steps that resolved this issue.
Start Excel.
Go to File | Options.
Click the "Add-ins" item in the list box on the left-hand side of the Excel Options dialog.
Select the "COM Add-ins" item of the Manage combo box.
Click the "Go..." button.
Clear the check box for the "Team Foundation Add-in" entry and click the "OK" button.
The "Custom Toolbars" group is no longer in the custom ribbon tab.
I have customized the Office Ribbon adding a new tab to the Word ribbon by creating a custom XML file. The customization is in a template in the Word start-up directory. I am using Word 2016. It works under Word 2016; however it does not work in Word 2010. When opening a document in Word 2010 I get the dreaded "Error in hidden module" message. After hours of debugging and researching I cannot find the cause of this error in my VBA code.
All the users in my company should be using Word 2016, however I must assume that some users will still be using Word 2010.
If a user opens a document using Word 2010 I don't want my custom tab to be visible, that is I don't want the OnLoad event to fire.
I tried the following code in the OnLoad Event callback:
If Application.Version = "16" Then
Set myribbon = ribbon
Else
End
End If
In the other callbacks such as ToggleOn Action, getlabel, getTag, GetImage I checked for the Word Version like this:
Public Sub…
If Application.Version = "16" then
Do callback code
Else
End
End If
End Sub
However, the ribbon always loads and I could not find a way to stop it from loading. I also believe that you cannot hide a custom tab on the ribbon using VBA.
To solve this problem I did the following:
I put a template in the startup directory that checked for the correct version of Word. If the correct version was found, it loaded a template as an add-in from the users template directory with the ribbon customisation and my VBA code.
It works, but it means I have to distribute two templates to the users. Ideally I'd like to have to distribute only one template.
Is there a way to enable or prevent the OnLoad event firing, that is display a custom tab, depending on the version of Word detected?
Use getVisible callback.
XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab id="tab1" label="CUSTOM" getVisible="OnGetTabVisible">
<group id="group1" label="Group1">
<button idMso="SaveAll" label="Save All" size="large"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Callback:
Sub OnGetTabVisible(ctrl As IRibbonControl, returnVal)
If Val(Application.Version) = 14 Then
returnVal = False
Else
returnVal = True
End If
End Sub
UPDATE
I would suggest following resources:
RibbonX: Customizing the Office 2007 Ribbon
Excel 2007 VBA Programmer's Reference
Ron de Bruin Excel Automation
Hi I've Windows form with checkbox. I would like enable/disable single button attach into my ribbon. Wound somebody show me a right way?
Part of XML code Ribbon looks like this
<tab idMso="TabNewMailMessage">
<group id="Kompresja2"
label="Lab1">
<toggleButton id="Kompresja6"
imageMso="Smile"
onAction="ProcedureX"
getPressed="Wcisnieto"
getEnabled="Czytaj_stan"
label="Lab2"
size="large"
/>
</group>
</tab>
The getEnabled callback function (in your case Czytaj_stan) checks to see if the button is enabled or not - returns True if the button should
be enabled, False if not.
The getEnabled callback function is called whenever the ribbon-control is invalidated, which is whenever the office application decides it is needed, e.g. when it has been minimized, or when you make it by calling [IRibbonUI-object].InvalidateControl("Kompresja6") to invalidate just that control or [IRibbonUI-object].Invalidate() to redraw the whole ribbon ([IRibbonUI-object].InvalidateControlMso("ID") invalidates a built-in control).
The reference to the IRibbonUI-object needs to be set when the custom ribbon loads.
In order to make this work you need to:
Make sure you can get the reference to the IRibbonUI-object by adding an onLoad callback function in your customUI XML-tag: <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">.
Implement he Ribbon_Load callback function and set a reference to the IRibbonUI-parameter.
Implement the getEnabled function Czytaj_stan to decide when the button should be enabled or not.
Have your form-button first modify the conditions for enabled/disabled in Czytaj_stan, then call [IRibbonUI-object].InvalidateControl("Kompresja6") to invalidate the ribbon-button.
I have an Outlook add-in that has been used for the last couple of years. When creating a new email, I had added a group of controls to the ribbon that would appear on the inspector window.
With the advent of Outlook 2013 and the in-line response feature, these controls do not appear on the ribbon. There is a new message contextual tab that shows when the in-line response is activated, and ideally this is where I would have the controls show.
The RibbonType used for the existing controls is Microsoft.Outlook.Mail.Compose, but I cannot see any option for the contextual in-line response.
The only solutions I have found on the Internet use Add-in Express but I'm just using VSTO.
Does anybody know how I can get my controls to show on the contextual ribbon?
It is possible with the Ribbon xml, not with the designer !
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<contextualTabs>
<tabSet idMso="TabComposeTools">
<tab idMso="TabMessage">
##Place your content here##
</tab>
</tabSet>
</contextualTabs>
</ribbon>
</customUI>
I have created a pptm file with macros that open certain pptx templates. I then created a new tab with buttons for opening the files. I attached the macros I created to those buttons. All works great as long at my pptm file is open. But after I save it as a ppam file and install it as an add-in it no longer works. It seems the macros don't come along and the buttons are still trying to reference the macros via the pptx name.
Does anyone know a simple way to create a custom tab to launch predefined templates? Or load macros by default like Word does? Or fix my situation above? The only alternative I see is an add-in that will only show up under the Add-In's tab.
Are you manually creating the ribbon with the buttons? I use the Custom UI Editor Tool and it works like a charm.
Just create any macro in your .pptm, like this:
Sub SayHello(ByVal control As IRibbonControl)
MsgBox "hello"
End Sub
The (ByVal control As IRibbonControl) part is important.
Then save and close your .pptm.
Open the Custom UI Editor Tool. From that tool, click Open from the File menu and navigate to your .pptm and open it.
On the Insert menu, click Office 2010 Custom UI Part. This will create a new XML document that will be inserted into your .pptm.
You can then use sample snippets to start creating your ribbon, but the simplest is just from the Insert | Sample XML menu, just click on Custom Tab. This will insert:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="customTab" label="Custom Tab">
<group id="customGroup" label="Custom Group">
<button id="customButton" label="Custom Button" imageMso="HappyFace" size="large" onAction="Callback" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Where you see Callback in after onAction, replace it with the name of your macro. In our example above, it is SayHello, so it should now look like onAction="SayHello".
Click Save and then close the Custom UI Editor Tool.
Open your .pptm in PowerPoint and test that a tab called Custom Tab has been created. Navigate to it and click on the happy face button. You should now get a message box.
Go to the Backstage by clicking on File and click Save As... and then choose as the file type PowerPoint Add-in (*.ppam) and save it in any location. Note the location.
Go to File | Options | Add-in and then select PowerPoint Add-ins from the Manage dropdown at the bottom of the dialog. Then click Go. Click **Add New...* and add your add-in from the location you saved it.
Close PowerPoint and reopen it. The Custom Tab ribbon should be there. Click on the happy face icon to run your SayHello macro.
The only thing you'll need to do beyond this is to customize your macros and ribbon controls they way you need them and for what you want them to do. Check out this link for more info: Customizing the 2007 Office Fluent Ribbon for Developers