Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default CommandBarButton with toggle property (up & down)

Hi,
I create a new CommandBar, I had a button, more or less like this :

With CommandBars.Add(Name:=stCBarName)
With .Controls.Add(Type:=msoControlButton, _
temporary:=True)
etc.

I would like that the button be a "toggle button" that offers 2 possible
states "up" and "down".
Is that possible .. and how.
Thank you in advance.

Jean-Pierre Bidon
Interstat
5 place de la République
75003 Paris
Tél: 01 45 49 19 17


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default CommandBarButton with toggle property (up & down)

Here is one method that is supported by commandbars:

http://support.microsoft.com/?id=161926
XL97: How to Place a Checkmark Next to a Menu Item

http://support.microsoft.com/?id=213735
XL2000: How to Place a Check Mark Next to a Custom Menu Item

http://support.microsoft.com/default...63&Product=xlw
Sample Macro to Add Check Marks to Custom Menu Commands (xl5/95)

--
Regards,
Tom Ogilvy


"Jean-Pierre Bidon" wrote:

Hi,
I create a new CommandBar, I had a button, more or less like this :

With CommandBars.Add(Name:=stCBarName)
With .Controls.Add(Type:=msoControlButton, _
temporary:=True)
etc.

I would like that the button be a "toggle button" that offers 2 possible
states "up" and "down".
Is that possible .. and how.
Thank you in advance.

Jean-Pierre Bidon
Interstat
5 place de la République
75003 Paris
Tél: 01 45 49 19 17



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default CommandBarButton with toggle property (up & down)

Try something like the following code:

Sub AAA()
Dim CmdBar As Office.CommandBar
Dim Ctrl As Office.CommandBarButton
On Error Resume Next
Application.CommandBars("Chip").Delete
On Error GoTo 0
Set CmdBar = Application.CommandBars.Add(Name:="Chip", temporary:=True)
Set Ctrl = CmdBar.Controls.Add(Type:=msoControlButton)
Ctrl.Caption = "click me"
Ctrl.State = msoButtonUp
Ctrl.OnAction = "'" & ThisWorkbook.Name & "'!TheProc"
CmdBar.Visible = True

End Sub

Sub TheProc()
With Application.CommandBars.ActionControl
If .State = msoButtonDown Then
.State = msoButtonUp
Else
.State = msoButtonDown
End If
End With
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Jean-Pierre Bidon" wrote in message
...
Hi,
I create a new CommandBar, I had a button, more or less like this :

With CommandBars.Add(Name:=stCBarName)
With .Controls.Add(Type:=msoControlButton, _
temporary:=True)
etc.

I would like that the button be a "toggle button" that offers 2 possible
states "up" and "down".
Is that possible .. and how.
Thank you in advance.

Jean-Pierre Bidon
Interstat
5 place de la République
75003 Paris
Tél: 01 45 49 19 17


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
Does 2007 Office VBE Editor CommandBarButton .OnAction Property wo fgrose Excel Programming 0 August 2nd 07 03:54 AM
CommandBarButton onClick [email protected] Excel Programming 2 May 24th 06 03:20 PM
.Parameter property of CommandBarButton Gregory Kip[_3_] Excel Programming 2 May 22nd 06 09:43 PM
Self deleting CommandBarButton possible? Bruno G. Excel Programming 2 January 11th 05 12:13 PM
CommandBarButton.FaceId=? Tom Ogilvy Excel Programming 1 September 17th 03 05:28 PM


All times are GMT +1. The time now is 12:00 AM.

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

About Us

"It's about Microsoft Excel"