Ribbon Editor

22
Ribbon Editor andypope.info /vba/ribboneditor.htm RibbonX Visual Designer Although the add-in has been tested and create a backup file when used there is always the potential for an error to lead to the corruption of a workbook. Therefore I strongly recommend that you take your own copy of the file before using the designer. The RibbonX Visual Designer is a VBA add-in designer to help with the construction of Ribbon interfaces. The add-in will now work with PowerPoint and Word files as well as Excel. In order to construct and preview files in PowerPoint or Word the add-in will attempt to reference the correct version of the application. If you have versions prior to 2007 installed then you may need to manually open the relevent application before opening the designer or loading RibbonX. Under normal circumstances the correct version of the application will be opened if no instances are currently open. If you recieve the warning message simply save and close any open instances of the application before trying again. Obviously this is not an issue when working with Excel files. When the add-in is loaded 2 new buttons will appear on the Developer Tab.

description

Ribbon Editor

Transcript of Ribbon Editor

Page 1: Ribbon Editor

Ribbon Editorandypope.info /vba/ribboneditor.htm

RibbonX Visual Designer

Although the add-in has been tested and create a backup file when

used there is always the potential for an error to lead to thecorruption of a workbook. Therefore I strongly recommend that youtake your own copy of the file before using the designer.

The RibbonX Visual Designer is a VBA add-in designer to help withthe construction of Ribbon interfaces. The add-in will now work withPowerPoint and Word files as well as Excel.In order to construct and preview files in PowerPoint or Word theadd-in will attempt to reference the correct version of the application.If you have versions prior to 2007 installed then you may need tomanually open the relevent application before opening the designeror loading RibbonX. Under normal circumstances the correct versionof the application will be opened if no instances are currently open. Ifyou recieve the warning message simply save and close any openinstances of the application before trying again. Obviously this is notan issue when working with Excel files.

When the add-in is loaded 2 new buttons will appear on the DeveloperTab.

Page 2: Ribbon Editor

The Designer menu contains the Office Applications that can now beused.

I have also added a button to the Office Menu.

Page 3: Ribbon Editor

Use the Load RibbonX to work with existing Excel files even if theydo not currently contain ribbonx code. You can import, modify,preview and save the files ribbonx information.

Use the Designer to create, preview and save a new file with ribbonx information.

The program can handle Excel: .xlsx, .xlsm, .xltx, xltm, .xlam and .xlsb filesPowerPoint: .pptx, .pptm, .potx, .potm and .ppam files Word: .docx, .docm, .dotx and.dotm files

Note:

In order for the RibbonX Visual Designer to modify a file it mustcheck that the file is not currently open. This task requires access tothe VBA Project object model. Therefore you need to enable thisproperty manually.

Use Office Button > Excel Options > Trust Center > Trust Center Settings > Macrosettings.

Page 4: Ribbon Editor

With the designer loaded you can modify built-in items such as thevisibility of a Tab or Group. Or more likely you can create your owncustom interface.

To build you custom interface start by selecting the node that will actas the parent of the item you wish to add. So to add a new Tab []select the Tabs node []in the Ribbon view. You can then select theTab [] item from the toolbox and either double-click or use the InsertItem button [

] to insert the new item.

PropertiesThe details of the selected item in the Ribbon are displayed in the Properties list.

Load RibbonX allows you to import, modify, preview and eventuallysave a files existing ribbonx information. Designer allows you tocreate, preview and eventually save a file with ribbonx information.The program can handle .xlsx, .xlsm and .xlam workbooks.

With the designer loaded you can modify built-in items such as thevisibility of a Tab or Group. Or more likely you can create your owncustom interface.

To build you custom interface start by selecting the node that will actas the parent of the item you wish to add. So to add a new Tab []select the Tabs node []in the Ribbon view. You can then select theTab [] item from the toolbox and either double-click or use the InsertItem button [

Page 5: Ribbon Editor

] to insert the new item.

PropertiesThe details of the selected item in the Ribbon are displayed in the Properties list.

Each property is one of the following,

Dropdown list of predefined options. e.g. the size property can benormal or large; enabled property can be true or false.

Textbox where descriptive text or values can be entered. e.g. the labelor supertip properties.

Page 6: Ribbon Editor

Mso Image selector for picking of built-in imageMso property. Thesize of images displayed will depend on the setting of the sizeproperty.

When selected a sub form will display available icons. The image size in the gallery isdependent upon the current setting of the size property. On the sub form both the largeand small icon is displayed for the selected icon.

Image file selector for picking custom image files.

The add-in will display a viewer containing all existing imagery for the file. The Browsebutton can be used to add new images.

Page 7: Ribbon Editor

Please note that if you are using .png graphics and callback routines to dynamicallyload files you will require additional coding routines to enable the loading of png files.

Fortunately Stephen Bullen has posted a file with the required codes. LoadPictureGDI

CallbacksAvailable callbacks are displayed in the Callbacks list.

Page 8: Ribbon Editor

When you check the callback an automatic routine stub name iscreated. You can change this, if for example you are using a singlecallback routine to handle the same event across multiple items.

CustomUI XMLThis is a read-only copy of the information that will be written to thefile.

Only for use if you want to manually maintain your files. You cancopy this to the clipboard.

Callback StubsThis is a read-only copy of vba callbacks that you can copy and pasteinto your file.

Page 9: Ribbon Editor

The code does not include any additional variable declarationrequired to make the VBA function.

CustomUI Rel XMLThis is a read-only copy of the xml required if you are using customimages.

Page 10: Ribbon Editor

Only for use if you want to manually maintain your files. You cancopy this to the clipboard.

Moving custom items within the Ribbon.

As well as the Insert Item [

] there are controls for moving and removing custom items within theRibbon.

Delete Item [

] will remove the selected item and all items contained within fromthe ribbon.

Move Item Up [

Page 11: Ribbon Editor

] will move the selected item up, taking along all items containedwithin.

Move Item Down [

] will move the selected item down, taking along all the itemscontained within.

Demote Item [

] will move the selected item within the item immediately below it,taking all the items contrained within.

Premote Item [

] will move the selected item out of and below the containing item,taking all the items contained within.

Clone Item [

] will create a copy of the selected item and all the items within it. All the properties and callbacks will be copied. The Id property will bea unique defalt value.

The these controls it is possible to nest items within each other. e.gbuttons within menus, or Items within a Gallery.

All of the movement buttons will only perform the task if it is valid.

Controls

I have created a set of example files demonstrating the variouscontrols that can be used on the ribbon. There are Excel, PowerPointand Word versions.

Download ControlGallery

Page 12: Ribbon Editor

Demonstrates the use of Button, Checkbox and Editbox.

Demonstrates the use of Combobox, Dialog launcher and Dropdown.

Demonstrates the use of custom images, Gallery and DynamicGallery.

Demonstrates the use of Menus, Split and Toggle buttons.

Demonstrates the use of Box, Button Group, Label and Separatorformatting items.

Page 13: Ribbon Editor

Office MenuYou can also add ribbonx to the Office menu [].

This will result in a new item on the Office menu.

Download OfficeMenu

Page 14: Ribbon Editor

Quick Access ToolbarYou can also create buttons and groups on the Quick Access Toolbar(QAT) []. Note this requires the setting he CustomUI property"StartFromScratch" to true.

Document controls will only appear when the specific workbook hasfocus.

Results in the following appearance of the ribbon. Note the bordersaround the icons which denote they are document specific.

Download QATDocument

Shared Controls will be available to all open workbooks.

Page 15: Ribbon Editor

Results in the following appearance of the ribbon.

Download QATShared

Contextual Tabs

It is possible to add tabs [] to existing Contextual Tabs [].

Results in the following appearance of the ribbon when a Chart orChart object is selected

Page 16: Ribbon Editor

Download ContextualTabs

Namespace

By using a namespace you can allow multiple files to share parts ofthe ribbon use customize.

The following screen shots show the properties of 2 workbooks withboth private and shared sections of the ribbon.

Page 17: Ribbon Editor

Which results in the following appearance of the ribbon whenNamespaceA.xlsm is active.

Which results in the following appearance of the ribbon whenNamespaceB.xlsm is active.

Download Namespaces

Command

By using the Command item you can repurpose the built-in functionof buttons. The following repurposes the Bold button.

You need to define callback

Page 18: Ribbon Editor

Which will generate the following VBA stubs.

In the download file I have added a simple message boxrxBold_repurpose routine.

Download Commands

Download all Excel examples

Download all PowerPoint examples

Page 19: Ribbon Editor

Download all Word examples

Download latest RibbonX Visual Designer

For instructions on how to install add-in.

To replace existing add-in with later version you simply need tooverwrite the existing add-in. Make sure Excel is not runningotherwise you will not be able to replace the file.

Version History

Word and PowerPoint example files for ControlsPart3 has beenamended slightly as the dynamic gallery was not populatingwhen used with Office 2010

Version 1.94 May 2014

Added Supertip attribute to Gallery control

Bug fix for gallery items with no label attribute

Version 1.93 December 2010

Bug fix Office Button menu entry points where notworking

Version 1.92 April 2010

Added .xlsb file type

Version 1.91 February 2010

Bug fix when handling incorrect application version forPowerPoint and Word

Page 20: Ribbon Editor

Bug fix for handling image formats not supported by VBAcontrols that maybe valid for use in the ribbon

Version 1.9 January 2010

Added PowerPoint and Word capabilities

Added Image viewer for working with existing customimages

Version 1.7 December 2009

Bug fixed to allow reloading of formatted built-in groups

Version 1.6 October 2009

Added OnAction callback to Dropdown control

Added check for Trusted Access to VBA Project

Version 1.5 September 2009

Addition of entry points within Office menu

Correction to handling of positioned controls

This Addin uses routines and techniques provided by the following.

Jan Karel Pieterse (www.jkp-ads.com)

JKP Application Development Services© Class to EditXML office file

Ron de Bruin (www.rondebruin.nl)

Zip file creation

Ron also has a great collection of Ribbon related articles.

Ken Puls (www.excelguru.ca)

Additional coding to the XML class for the customUIrelationship to the rels file.

Page 21: Ribbon Editor

Randy Birch (http://vbnet.mvps.org/index.html)

UNC file functions

I also made extensive use of the RibbonX book Customizing theOffice 2007 RibbonBy Robert Martin, Ken Puls, Teresa HennigIncluding trying all the example download files.

The following error messages may be encountered if you do not havethe required libraries registered on your pc.

"Can't find project or library" or

"Cannot run the macro btnLoadFile_click. The macro may not be available in thisworkbook or macros maybe disabled"

The 2nd error is of course possible if Macros are not enabled.

Libraries

Visual Basic For Applications

Microsoft Excel 12.0 Object Library

OLE Automation Microsoft Office 12.0

Object Library Microsoft Forms 2.0

Object Library Microsoft Windows Common Controls 6.0 (SP6)

Microsoft XML, v3.0

Microsoft Word 12.0 Object Library

Microsoft PowerPoint 12.0 Object Library

Also check problems mentioned on page for the 2010 version.

The add-in will not function in Excel 64-bit. Due to certain 32-bit controls not being available in 64-bit versions.

Page 22: Ribbon Editor

Download latest RibbonX Visual Designer