Face Ids - Custom
Custom Toolbar Icons
If you are creating custom commandbar controls for Office then you have several options.
The easiest method is just to use the Visual Studio Image Editor in conjunction with the Picture and Mask properties.
Visual Studio Image Editor
The editor provided in Visual Studio has an extensive set of tools for creating and editing images
The editor can work with all the common file formats (png, bmp, jpeg and tiff)
CopyFace and PasteFace
This method will copy the controls image to the clipboard
Some button images are blank and some are missing ??
The blank ones will copy without any problems but you will get an error if you try and copy an image from a control that doesn't has one.
This example finds the first control on the commandbar named "Custom".
If the first control on this custom toolbar is a button, the FindControl method is used to find the Copy button (on the standard toolbar) and then copies the face from this button to the button on the custom toolbar.
Dim objCustomControl As Office.CommandBarControl
Dim objStandardControl As Office.CommandBarControl
Set objCustomControl = CommandBars("Custom").Controls(1)
If objCustomControl.Type = 1 Then
Set objStandardControl = CommandBars.FindControl(Type:=MsoControlButton, _
Picture and Mask
These two new properties were added to the CommandBarButton in Office 2002.
Picture and Mask can also support gradients in Office 2003 running on Windows XP using themes.
.Picture = Worksheets(1).Shapes(2).Picture
Creating a Transparent Image
Select the Project in the Solution Explorer
Right click and select Properties
Display the Resources tab
Select (Add Resource > New Image > BMP Image)
Enter a meaningful name into the Add New Resource dialog box
The size defaults to (48x48) change this to (16x16)
In this example we are going to use "InsertData"
Pressing Add will display the Visual Studio Image Editor
Create your image (using green (or clear) for your background colour )
Remember that you can copy button images directly from existing toolbars and paste them into your editor using (Edit > Paste)
Once your icon is finished save it
This will be the icon used for Picture property, so now we need to create the corresponding icon for the Mask property.
Select (File > Save Resource As..)
Because our original bitmap is called "InsertData" we are going to save this as "InsertData_mask"
Creating the Mask icon is quite straightforward
Everything you want displayed in the foreground must be in black
Everything you want to be transparent must be in white
Make the necessary changes and save
You then have to add this file to the resources
Select (Add Resource > Add Existing File)
Browse to the Resources folder of your solution and select the file
If you want to remove a resouce it is not sufficient to delete it using Solution Explorer. You must click on "Remove Resouce" from the resources tab.
The Picture & Mask properties cannot be used if the toolbar has been protected.
You must remove any toolbar protection before these properties can be used.
© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext