+ Reply to Thread
Results 1 to 3 of 3

Command Button from Control Toolbox

  1. #1
    Jim May
    Guest

    Command Button from Control Toolbox

    Can I (somehow) have a command button which is stationary (at a given
    position - on Workbook open) and remains Visible and available as I
    activate to review different Worksheets? (a "floater" button)..
    Thanks in Advance,


  2. #2
    Registered User
    Join Date
    10-28-2003
    Posts
    21

    here ya go...

    you can make a separate toolbar for excel, which can float or you can attach to the other toolbars at top. You can make it visible upon opening, and then hide it before closing. The following will create this toolbar with two buttons that link to a macro

    private sub workbook_open
    goto skp
    error1:
    Call ButtonInstall
    skp:
    on error goto error1
    Application.CommandBars("mybuttons").Visible = True
    on error goto 0
    end sub

    private sub workbook_close
    Application.CommandBars("mybuttons").Visible = false
    end sub

    sub ButtonInstall
    Dim NewToolbar As Object
    Dim NewButton As Object
    Set NewToolbar = Application.CommandBars.Add(Name:="mybuttons", temporary:=False)
    NewToolbar.Visible = True
    Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton, ID:=2950)
    With NewButton
    .FaceId = 583
    .OnAction = "Name of Macro1 here"
    .Caption = "Macro1 description here"
    End With
    Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton, ID:=2950)
    With NewButton
    .FaceId = 45
    .OnAction = "Name of Macro2 here"
    .Caption = "Macro2 description here"
    End With
    End Sub

  3. #3
    Jim May
    Guest

    Re: Command Button from Control Toolbox

    Thanks lcorey1;
    Much appreciated


    "lcoreyl" <[email protected]> wrote
    in message news:[email protected]:

    > YOU CAN MAKE A SEPARATE TOOLBAR FOR EXCEL, WHICH CAN FLOAT OR YOU CAN
    > ATTACH TO THE OTHER TOOLBARS AT TOP. YOU CAN MAKE IT VISIBLE UPON
    > OPENING, AND THEN HIDE IT BEFORE CLOSING. THE FOLLOWING WILL CREATE
    > THIS TOOLBAR WITH TWO BUTTONS THAT LINK TO A MACRO
    >
    > private sub workbook_open
    > goto skp
    > error1:
    > Call ButtonInstall
    > skp:
    > on error goto error1
    > Application.CommandBars("mybuttons").Visible = True
    > on error goto 0
    > end sub
    >
    > private sub workbook_close
    > Application.CommandBars("mybuttons").Visible = false
    > end sub
    >
    > sub ButtonInstall
    > Dim NewToolbar As Object
    > Dim NewButton As Object
    > Set NewToolbar = Application.CommandBars.Add(Name:="mybuttons",
    > temporary:=False)
    > NewToolbar.Visible = True
    > Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton,
    > ID:=2950)
    > With NewButton
    > .FaceId = 583
    > .OnAction = "Name of Macro1 here"
    > .Caption = "Macro1 description here"
    > End With
    > Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton,
    > ID:=2950)
    > With NewButton
    > .FaceId = 45
    > .OnAction = "Name of Macro2 here"
    > .Caption = "Macro2 description here"
    > End With
    > End Sub
    >
    >
    > --
    > lcoreyl
    > ------------------------------------------------------------------------
    > lcoreyl's Profile: http://www.excelforum.com/member.php...fo&userid=2042
    > View this thread: http://www.excelforum.com/showthread...hreadid=557584



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1