3

In %appdata%\Microsoft\Office\olkapptitem.officeUI I have:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="DoIt">
    <ribbon startFromScratch="false">
        <tabs>
            <tab idMso="TabMail">
                <group id="group1" label="Hazaa!">
                    <button id="one" onAction="DoIt2" label="hi" visible="true"/>
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

In Outlook, in the VBA editor, I have a module called Module1 that has:

Option Explicit

Sub DoIt(ribbon As IRibbonUI)
    MsgBox "hi"
End Sub

Sub DoIt2(control As IRibbonControl)
    MsgBox "bye"
End Sub

However, neither DoIt or DoIt2 will run. If I take out the parameters from DoIt2 then when I click the button it will run, but not the other way.

Any help is appreciated.

IMTheNachoMan
  • 5,343
  • 5
  • 40
  • 89
  • That is because you are not passing anything into the parameter. On click you are running `DoIt2` but since you have a non-optional parameter of `control` it won't run successfully. Do you get an error? – Chrismas007 Jan 08 '15 at 22:06
  • Christmas007, these are ribbon callbacks. You shouldn't pass anything to them, they are called by Outlook. – Eugene Astafiev Jan 09 '15 at 13:35

1 Answers1

4

You can't define ribbon callbacks in VBA. You need to develop an add-in if you want to customize the Ribbon Ui using callbacks. Outlook, unlike any other Office application, doesn't support customizing the Ribbon UI using VBA.

The Ribbon UI is described in depth in the following series of articles in MSDN:

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45