Hack 11 Create a Custom Button Image![]() ![]() bitmapeven a favorite photo.Putting a company logo or even a picture onto a toolbar button can give your Word workspace a truly custom look. Turning any graphic into a toolbar button is easier than it sounds.The image must be a .bmp, .jpg, or .gif file. The optimal dimensions follow:16 16 pixels24-bit color depth Word will scale oversized or not perfectly square images, but you'll be more satisfied with the results if you scale and crop the image yourself.If you want your image to appear cut out, like most of the Word button images, you'll also need a mask for your image. The mask is a second image that defines the boundaries of the first. To create the mask, blacken the area of the 16 16 square occupied by your image and leave the rest white. The white area of your mask will be filled in by the toolbar color. You can use an image-processing program such as PhotoShop to do this, but many other programs, including SnagIt from TechSmith (http://www.techsmith.com), offer inexpensive image-editing tools.For example, to create a button image using the animal shown in Figure 2-29, first scale it down to 16 16 pixels and then create a mask, as shown (and magnified considerably) in Figure 2-30. Figure 2-29. The base image for a new toolbar button![]() Figure 2-30. The "mask" image for a toolbar button![]() 2.10.1 The CodeThe following macro creates a new floating toolbar with just one button, containing our sample image. From there, you can use the Copy Button Image and Paste Button Image commands to place the image as needed. Sub DisplayNewImage( )Running the macro produces the toolbar shown in Figure 2-31. Figure 2-31. A button image created from a bitmapped image![]() 2.10.2 Hacking the HackIf you'd rather hack on the existing buttons, you can capture and save the button images to file.The following macro goes through every button on all the toolbars and saves the images and their masks to a folder called C:\Buttons, which you should create before running the macro. Each file is named using the control's ID and saved as a .bmp file. Sub GetButtonImageAndMask( )Once you've got the bitmap files, you can open and edit them as shown in Figure 2-32 (a screen shot from the SnagIt program mentioned earlier). Figure 2-32. After saving the button images as files, you can edit them with an image-editing software program![]() |