Microsoft Office Tutorials and References
In Depth Information
Simulating a Toolbar with a UserForm
Figure 15-15: Another UserForm without a title bar.
One problem is that, without a title bar, the user has no way to reposition the dialog box. The
solution is to use the MouseDown and MouseMove events, as described in the preceding section.
Because the FindWindowA function uses the UserForm’s caption, this technique won’t
work if the Caption property is set to an empty string.
Simulating a Toolbar with a UserForm
Creating a custom toolbar in versions prior to Excel 2007 was relatively easy. Beginning with
Excel 2007, you can no longer create a custom toolbar. More accurately, you can still create a
custom toolbar with VBA, but Excel ignores many of your VBA instructions. Beginning with Excel
2007, all custom toolbars are displayed in the Add-Ins➜Custom Toolbars Ribbon group. You
can’t move, float, resize, or dock these toolbars.
This section describes how to create a toolbar alternative: a modeless UserForm that simulates a
floating toolbar. Figure 15-16 shows a UserForm that may substitute for a toolbar.
This example, named simulated toolbar.xlm , is available on the companion CD-ROM.
The UserForm contains eight Image controls, and each executes a macro. Figure 15-17 shows the
UserForm in the VBE. Notice that
h The controls aren’t aligned.
h The UserForm isn’t the final size.
h The title bar is the standard size.
 
Search JabSto ::




Custom Search