Custom Excel 2013 UI does not appear to be working - vba

I have an Add-in created in Excel 2013 that I am attempting to call through a custom ribbon created through Custom UI Editor for Microsoft Office.
I have created the XAML and it is as follows:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="false">
<tabs>
<tab id="customTab" label="TestTab">
<group id="customGroup" label="TestGroup">
<button id="scanStart" label="Scan Test" imageMso="HappyFace" size="large" onAction="Yolo_eventhandler" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
within the Add-in I have the following:
Sub Yolo_eventhandler(control As IRibbonControl)
MsgBox "YOLO"
End Sub
I have checked the add-in is installed, and I have confirmed the add-in is running when excel starts by adding a msgbox in the add-ins "onLoad" event. I can also run macros that I have manually added to the ribbon.
The error message I am getting is: "Cannot run the macro 'Yolo_eventhandler'. The macro may not be available in this workbook or all macros may be disabled".
I have checked my trust settings and the folder this add-in is located (the default add-ins folder) is definately trusted.
Interestingly, when I copy the eventhandler code to a module in an xlsx file I also have open it works perfectly.
Can anyone suggest how to get this correctly firing from the add-in?

I managed to resolve this issue - I was missing a reference to the "Microsoft Office 15.0 Object Library" in the add-in I was trying to call this from. It was hard to find this error as the ribbon would not give me this error, it was only when I went into my add-in and tried to run another function and it wouldn't compile. Thank you very much for your help!

Related

Display a custom tab on Word Ribbon depending on the version of Word detected?

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

Adding controls to Outlook 2013 "inline response" contextual ribbon

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>

VB 2010 Open Word document and Hide Office Ribbon

I am able to open a Word document from within my VB 2010 application. I need to hide the MS Office ribbon and set the Show Ruler option to false upon opening the document. Is there a way to do it?
Try adding ribbon <startFromScratch = "true"> at the begining of the ribbon xml code. The code might look something like this:
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon startFromScratch="true">
'your code here
</ribbon>
</customUI>

PowerPoint 2007 VBA - Unable to Get Ribbon Button Working

Starting today, no custom button in my PowerPoint 2007 ribbon will work. Each time I click the button, the following error message appears: "The macro cannot be found or has been disabled because of your security settings."
I've Googled this issue to death and found no solution. I'm at a complete loss.
Here is the code for the macro:
Sub RunThisCode()<br>
MsgBox "Yes, this works", vbExclamation
End Sub
I've tried both with and without the ByVal control as IRibbonControl. No luck either way.
And the XML code
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
<ribbon>
<tabs>
<tab idMso="TabHome">
<group id="CustomGroup" label="MyGroup">
<button id="btnTest" label="TestButton" imageMso="HappyFace" size="large" onAction="RunThisCode" keytip="S" />
</group>
</tab>
</tabs>
</ribbon>
My installation is running through Softricity SoftGrid as a virtual installation, for what it's worth.
Any ideas?
Turns out there was a compiling error in my code that, oddly, 2007 didn't pick up, but 2010 did. Though, I am still confused why even the basic macro posted above wasn't working.

How to add tabs to PowerPoint 2010 that call macros

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