PC Review


Reply
Thread Tools Rate Thread

CommandBarButton with toggle property (up & down)

 
 
Jean-Pierre Bidon
Guest
Posts: n/a
 
      6th Nov 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      6th Nov 2007
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
>
>
>

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      6th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Does 2007 Office VBE Editor CommandBarButton .OnAction Property wo =?Utf-8?B?Zmdyb3Nl?= Microsoft Excel Programming 1 2nd Aug 2007 05:50 PM
Can't set CommandBarButton Tag property? 280Z28 Microsoft Outlook Interoperability 1 14th Jun 2006 06:59 PM
.Parameter property of CommandBarButton Gregory Kip Microsoft Excel Programming 2 22nd May 2006 09:43 PM
Toggle Visible Property for each Record in a Continuous Subform =?Utf-8?B?RGV2RGFuaWVs?= Microsoft Access Form Coding 4 4th Feb 2006 08:20 PM
Set CommandBarButton.Picture property (c++) Eric Microsoft Outlook Program Addins 12 24th Jan 2004 12:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:03 PM.