Create Floating Toolbar (not Menu)

  • A few days ago a knowledgeable Ozgrid member, RoyUk, was kind enough to help me with sample code to create a custom floating menu which appears on opening the workbook. It works brilliantly, but I'd like to adapt it so that I can create a floating toolbar, which is fully expanded upon opening, where the button faces are plain text which I designate.


    Let's suppose the macros I want the buttons to trigger are called MacroA and MacroB, and that the text on the buttons should read "Do A" and "Do B".


    I'd appreciate any help; my knowledge of VBA code at present is meager. Perhaps it would be easiest for you and me both if you could help by placing the code in the context of his code (see below) with the odd comment to steer me as to what's going on.


    His code appears here


    http://www.ozgrid.com/forum/showthread.php?t=62665


    It's in Item #10


    but for convenience here his code which goes in a) a standard module and b) the ThisWorkbook module.


    a) code for a standard module




    b) code for the ThisWorkbook module.


    Code
    1. Option Explicit
    2. Private Sub Workbook_BeforeClose(Cancel As Boolean)
    3. Call Delete_Menu
    4. End Sub
    5. Private Sub Workbook_Open()
    6. Call Create_Menu
    7. End Sub
  • Re: Create Floating Toolbar (not Menu)


    I am withdrwaing this question so that I can seek help elsewhere without contraneing the crosspost ban.


    Roy, thanks for the code you provided, it makes menus very well, but what I've been asking for is how to make toolbars with buttons.

  • Re: Create Floating Toolbar (not Menu)


    Maybe this is what you want - a floating toolbar with two buttons


  • Re: Create Floating Toolbar (not Menu)


    Thanks for the clarification Roy.


    Meanwhile I have learned a solution which I'll share here for any other similarly green VBA newbies.


    This is an example for creating an on-the-fly toolbar which is created on opening, and deleted on closing, the workbook.


    In this example the toolbar buttons trigger three simple example macros, called


    The buttons on the toolbar are simple text buttons. After some meditation I decided to label them "Yellow", "Red" and "Chicken".


    Paste this code in the ThisWorkbook module:



    and paste this in a standard module:



    Save, close, reopen and volia! Yellow! Red! Chicken! :sing:

  • Re: Create Floating Toolbar (not Menu)


    Your example creates a fixed or docked toolbar, my last post is a floating toolbar which is what I thought that you wanted. Anyway, there are now examples for most types that may be required.