K
K Dales
I have created a custom "Calculation" toolbar that gives
me the functions "Calc Sheet", "Calc Full", and "Calc
Now." I also added a button that uses VBA code to toggle
between Manual, Automatic, and Semiautomatic calc modes.
The code also changes the caption on the button to
read "MANUAL", "AUTO" or "SEMI" depending on the currently
selected mode. So far so good...
The problem: When I start up Excel, the caption on my
button does not necessarily reflect the current
calculation mode. It always comes up as "AUTO." As soon
as I press the button it reads the mode and the caption
changes appropriately, but I sure would like to know by
that button what mode I am in when I start up, without
having to press the dang thing.
I have tried various routines to run on workbook open,
activate, etc... I try reading the current calculation
mode and setting the button caption accordingly. The
routines work fine when I test them with Excel already up
and running, so I am fairly confident the code works, but
it still displays improperly when I first start Excel.
Perhaps it is timing - that I am trying to read the calc
mode when it is still in its default setting, before
applying any saved settings? I still can't figure it
out. Anyone out there who can help?
Here's the code to toggle the mode and set the caption - I
have it in my Personal.xls workbook:
Sub CalcMode()
Dim CurrentMode As Integer
CurrentMode = Application.Calculation
Select Case CurrentMode
Case xlCalculationAutomatic
Application.Calculation = xlCalculationManual
Case xlCalculationManual
Application.Calculation = xlCalculationSemiautomatic
Case xlCalculationSemiautomatic
Application.Calculation = xlCalculationAutomatic
Case Else
Application.Calculation = xlCalculationAutomatic
End Select
CurrentMode = Application.Calculation
Select Case CurrentMode
Case xlCalculationAutomatic
Application.CommandBars("Calculation").Controls
(1).Caption = "AUTO"
Case xlCalculationManual
Application.CommandBars("Calculation").Controls
(1).Caption = "MANUAL"
Case xlCalculationSemiautomatic
Application.CommandBars("Calculation").Controls
(1).Caption = "SEMI"
Case Else
Application.CommandBars("Calculation").Controls
(1).Caption = "???"
End Select
End Sub
Thanks in advance...
K Dales
me the functions "Calc Sheet", "Calc Full", and "Calc
Now." I also added a button that uses VBA code to toggle
between Manual, Automatic, and Semiautomatic calc modes.
The code also changes the caption on the button to
read "MANUAL", "AUTO" or "SEMI" depending on the currently
selected mode. So far so good...
The problem: When I start up Excel, the caption on my
button does not necessarily reflect the current
calculation mode. It always comes up as "AUTO." As soon
as I press the button it reads the mode and the caption
changes appropriately, but I sure would like to know by
that button what mode I am in when I start up, without
having to press the dang thing.
I have tried various routines to run on workbook open,
activate, etc... I try reading the current calculation
mode and setting the button caption accordingly. The
routines work fine when I test them with Excel already up
and running, so I am fairly confident the code works, but
it still displays improperly when I first start Excel.
Perhaps it is timing - that I am trying to read the calc
mode when it is still in its default setting, before
applying any saved settings? I still can't figure it
out. Anyone out there who can help?
Here's the code to toggle the mode and set the caption - I
have it in my Personal.xls workbook:
Sub CalcMode()
Dim CurrentMode As Integer
CurrentMode = Application.Calculation
Select Case CurrentMode
Case xlCalculationAutomatic
Application.Calculation = xlCalculationManual
Case xlCalculationManual
Application.Calculation = xlCalculationSemiautomatic
Case xlCalculationSemiautomatic
Application.Calculation = xlCalculationAutomatic
Case Else
Application.Calculation = xlCalculationAutomatic
End Select
CurrentMode = Application.Calculation
Select Case CurrentMode
Case xlCalculationAutomatic
Application.CommandBars("Calculation").Controls
(1).Caption = "AUTO"
Case xlCalculationManual
Application.CommandBars("Calculation").Controls
(1).Caption = "MANUAL"
Case xlCalculationSemiautomatic
Application.CommandBars("Calculation").Controls
(1).Caption = "SEMI"
Case Else
Application.CommandBars("Calculation").Controls
(1).Caption = "???"
End Select
End Sub
Thanks in advance...
K Dales