These functions can be used to manipulate the Excel ribbon.
The ribbon can be updated at any time, for example as PyXLL is loading via the xl_on_open
and
xl_on_reload
event handlers, or from a menu using using xl_menu
.
See the section on customizing the ribbon for more details.
Loads an image file and returns it as a COM IPicture object suitable for use when customizing the ribbon.
This function can be set at the Ribbon image handler by setting the loadImage attribute on the customUI element in the ribbon XML file.
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
loadImage="pyxll.load_image">
<ribbon>
<tabs>
<tab id="CustomTab" label="Custom Tab">
<group id="Tools" label="Tools">
<button id="Reload"
size="large"
label="Reload PyXLL"
onAction="pyxll.reload"
image="reload.png"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Or it can be used when returning an image from a getImage callback.
name (string) – Filename or resource location of the image file to load. This may be an absolute path
or a resource location in the form module:resource
.
A COM IPicture object (the exact type depends on the com_package setting in the config.
Returns the XML used to customize the Excel ribbon bar, as a string.
See the section on customizing the ribbon for more details.
Sets the XML used to customize the Excel ribbon bar.
xml – XML to set, as a string.
reload – If True, the ribbon bar will be reloaded using the new XML (does not reload PyXLL).
See the section on customizing the ribbon for more details.
Sets a single tab in the ribbon using an XML fragment.
Instead of replacing the whole ribbon XML this function takes a tab element from the input XML and updates the ribbon XML with that tab.
If multiple tabs exist in the input XML, the first who’s id attribute matches tab_id is used (or simply the first tab element if tab_id is None).
If a tab already exists in the ribbon XML with the same id attribute then it is replaced, otherwise the new tab is appended to the tabs element.
xml – XML document containing at least one tab element.
tab_id – id of the tab element to set (or None to use the first tab element in the document).
reload – If True, the ribbon bar will be reloaded using the new XML (does not reload PyXLL).
Removes a single tab from the ribbon XML where the tab element’s id attribute matches tab_id.
tab_id – id of the tab element to remove.
reload – If True, the ribbon bar will be reloaded using the new XML (does not reload PyXLL).
True if a tab was removed, False otherwise.
Many ribbon callbacks will be passed a control object as a IRibbonControl
object.
The control object corresponds to the ribbon control item handling the action.
This class is a Python wrapper around the Excel COM type of the same name.
Certain ribbon callbacks such as onLoad
will be passed an IRibbonUI
object.
This class is a Python wrapper around the Excel COM type of the same name.
Invalidates the cached values for all of the controls of the Ribbon user interface.
Invalidates the cached value for a single control on the Ribbon user interface.
control_id – Id of the control to invalidate.
Invalidating a control, repaints the screen and causes any callback procedures associated with that control to execute.
control_id – Mso id of the control to invalidate.
Activates the specified custom tab.
tab_id – Id of the tab to activate.