Toggle Button in a Toolbar

  • Thread starter Thread starter amitmohantybbsr
  • Start date Start date
A

amitmohantybbsr

Can anyone tell me how to create a toggle button in a Toolbar in Excel
VBA?

Thanks,
Amit
 
Here is an example that uses click to set the calculation mode to manual,
shift-click to automatic, and changes the tooltiptext to show whixh mode it
is in.

Sub SetCalculateMode() 'Shifted is automatic, unshifted is manual
Dim sMode As String
Dim nState As Long


If GetKeyState(vkShift) < 0 Then
Application.Calculation = xlAutomatic
sMode = "Automatic"
nState = msoButtonDown
Else
Application.Calculation = xlManual
sMode = "Manual"
nState = msoButtonUp
End If
With Application.CommandBars.ActionControl
.TooltipText = "Calculation mode is " & sMode
.State = nState
End With


End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top