问题
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.
回答1:
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:
- 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)
来源:https://stackoverflow.com/questions/27849923/outlook-2013-vba-ribbon-onload-not-firing