View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Can't get Control.State to work

You should set the caption (at startup) to reflect calc mode default
setting.

With CommandBars("myMacros").Controls("ToggleCalculatio n")
With Application
If .Calculation = xlCalculationAutomatic Then
.Caption = "Set Manual Calculation"
ElseIf .Calculation = xlCalculationManual Then
.Caption = "Set Automatic Calculation"
End If
End With
End With

Obviously, you'll need to decide the default startup caption since
"ToggleCalculation" won't work. I suggest you set the caption to what
the startup calc mode is. It might be helpful to identify the control
by putting "ToggleCalculation" in its Tag property, then iterate the
controls on your "myMacros" toolbar.

<aircode

Dim ctl As Object, CalcMode As Variant
CalcMode = Application.Calculation
For Each ctl In Commandbars("myMacros").Controls
If ctl.Tag = "ToggleCalculation" Then
If CalcMode = xlCalculationAutomatic Then
ctl.Caption = "Set Manual Calculation"
ElseIf CalcMode = xlCalculationManual Then
ctl.Caption = "Set Automatic Calculation"
Else
'set calc mode as desired if it's neither
Application.Calculation = xlCalculation[Automatic][Manual]
'set button caption accordingly
ctl.Caption = "Set [Manual][Automatic] Calculation"
End If
End If
Next ctl

</aircode

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc