Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Floating Command button


Is there any way I can create a command button that floats over severa
sheets instead of having to make the same command button and put it o
50 different sheets

--
kev_0
-----------------------------------------------------------------------
kev_06's Profile: http://www.excelforum.com/member.php...fo&userid=3504
View this thread: http://www.excelforum.com/showthread.php?threadid=55165

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Floating Command button

Attach it to a custom tool bar... make the bar visisble or invisible based on
the sheet selection...
--
HTH...

Jim Thomlinson


"kev_06" wrote:


Is there any way I can create a command button that floats over several
sheets instead of having to make the same command button and put it on
50 different sheets?


--
kev_06
------------------------------------------------------------------------
kev_06's Profile: http://www.excelforum.com/member.php...o&userid=35046
View this thread: http://www.excelforum.com/showthread...hreadid=551659


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Floating Command button


It's come to my attention that I have no idea how to add command button
to a commandbar

--
kev_0
-----------------------------------------------------------------------
kev_06's Profile: http://www.excelforum.com/member.php...fo&userid=3504
View this thread: http://www.excelforum.com/showthread.php?threadid=55165

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Floating Command button

Here is some sample code from one of my add-ins. Modify it to create a
toolbar instead of adding buttons to menu items (this code adds a
pop-up (submenu) and two commands to the Tools menu in Excel)

Option Explicit

' Procedure : AddFreezePopUp
' DateTime : 6/6/2006 19:34
' Author : Johnny Meredith
' Email :
' Purpose : Add Freeze pop-up menu to Tools menu in Excel
' Parameters: N/A
'---------------------------------------------------------------------------------------
Public Sub AddFreezePopUp()
On Error Resume Next

Dim cbmMenuBar As CommandBarPopup 'Main
menu bar
Dim cbcMenuItem As CommandBarPopup 'New
menu item

' Remove menu item if it exists.
Application.CommandBars(cMenuBarName).Controls("To ols") _
..Controls("Freeze").Delete

'Identify menu bar that will receive new item.
Set cbmMenuBar =
Application.CommandBars(cMenuBarName).Controls("To ols")

'Add menu item.
Set cbcMenuItem = cbmMenuBar.Controls.Add(Type:=msoControlPopup)

'Set property values of new menu item.
With cbcMenuItem
.Caption = "&Freeze"
.Tag = "Freeze"
End With

'Clean up references
Set cbmMenuBar = Nothing
Set cbcMenuItem = Nothing
End Sub

' Procedure : AddFreezeMenuItems
' DateTime : 6/6/2006 19:34
' Author : Johnny Meredith
' Email :
' Purpose : Add commands to new pop-up menu created in AddFreezePopUp
routine.
' Parameters: N/A
'---------------------------------------------------------------------------------------
Public Sub AddFreezeMenuItems()
On Error Resume Next

Dim cbmMenuBar As CommandBarPopup
'Main menu bar
Dim cbmFreezeMenu As CommandBarPopup
'New freeze popup
Dim cbcFreeze As CommandBarButton
'New freeze command
Dim cbcManage As CommandBarButton
'New manage command

'Remove menu item if it exists.

'Identify menu bar that will receive new item.
Set cbmMenuBar =
Application.CommandBars(cMenuBarName).Controls("To ols")
Set cbmFreezeMenu = cbmMenuBar.Controls("Freeze")

'Add menu item.
Set cbcFreeze = cbmFreezeMenu.Controls.Add(Type:=msoControlButton)
Set cbcManage = cbmFreezeMenu.Controls.Add(Type:=msoControlButton)

'Set property values of menu item.
'Freeze command
With cbcFreeze
.Caption = "Free&ze..."
.Tag = "Freeze"
.OnAction = "FreezeEntry"
End With

'Manage command
With cbcManage
.Caption = "&Manage..."
.Tag = "Manage"
.OnAction = "ManageEntry"
End With

'Clean up references
Set cbmMenuBar = Nothing
Set cbmFreezeMenu = Nothing
Set cbcFreeze = Nothing
Set cbcManage = Nothing
End Sub

' Procedure : DeleteCustomMenus
' DateTime : 6/6/2006 19:42
' Author : Johnny Meredith
' Email :
' Purpose : Remove custom pop-ups and commands added in
AddFreezePopUp &
' AddFreezeMenuItems routines
' Parameters: N/A
'---------------------------------------------------------------------------------------
Public Sub DeleteCustomMenus()
On Error Resume Next
Dim cbmMenuBar As CommandBarPopup
'Mail menu bar
Dim cbmFreezeMenu As CommandBarPopup
'Custom menu

'Delete Freeze pop-up
Set cbmMenuBar = Application.CommandBars("Worksheet Menu
Bar").Controls("Tools")
Set cbmFreezeMenu = cbmMenuBar.Controls("Freeze")

cbmFreezeMenu.Delete
End Sub

'Entry points for new commands
Public Function FreezeEntry()
On Error Resume Next
frmFreeze.Show
End Function

Public Function ManageEntry()
On Error Resume Next
frmManage.Show
End Function

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Floating Command button

This is very basic but it should give you a start... this code needs to be in
a standard code module.

Private Const MyBarName As String = "My Command Bar"

Public Sub AddMyBar()
Dim cbrMyBar As CommandBar
Dim btn As CommandBarButton

Set cbrMyBar = Application.CommandBars.Add(MyBarName)
cbrMyBar.Visible = True
Set btn = cbrMyBar.Controls.Add(Type:=msoControlButton)
With btn
.Style = msoButtonCaption
.Caption = "Tada"
.OnAction = "DoStuff"
End With
End Sub

Public Sub DeleteMyBar()
On Error Resume Next
Application.CommandBars(MyBarName).Delete
End Sub

Public Sub DoStuff()
MsgBox "Stuff"
End Sub

--
HTH...

Jim Thomlinson


"kev_06" wrote:


It's come to my attention that I have no idea how to add command buttons
to a commandbar.


--
kev_06
------------------------------------------------------------------------
kev_06's Profile: http://www.excelforum.com/member.php...o&userid=35046
View this thread: http://www.excelforum.com/showthread...hreadid=551659




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating command button Pat Excel Discussion (Misc queries) 4 April 7th 06 01:28 PM
Create floating button based on button click in menu ExcelMonkey Excel Programming 2 October 12th 05 06:43 PM
How can I create a Floating Command Button Karoo News Excel Programming 1 August 19th 05 11:19 AM
My Command Buttons keep floating on the sheet??? alondon Excel Programming 2 November 28th 04 12:35 AM
Floating Command Button - How to??? TinyTim Excel Programming 6 January 2nd 04 07:23 AM


All times are GMT +1. The time now is 03:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"