S
slim
Thanks to you guys I was able to write a macro that creates a toggle button
allowing me to toggle the calculation mode from automatic to manual. As I
explained in another thread I was having a problem when exiting excel with
the toggle button in manual mode..when I reopened excel the button would be
in manual mode (as it should be), but the calculation mode would be in
automatic.
I was able to fix that by adding a Workbook_Open subroutine to initialize
the button and calc mode. I put this sub under "This Workbook" in
personal.xls. I've included both macros below.
When I open up excel now, without directly opening up a file, no
problems..everything works great. The problem I have now is when I open up
excel by executing an actual excel file. When this happens the initialize
macro screws up because it seems to run before an actual workbook is opened.
The initialization macro will not work without an acual workbook open
because the calculation mode can't be set without a workbook being open.
Hopefully I've explained my problem well enough for you guys to understand.
Does anyone have any suggestions?
Thanks again.
Sub CalcMode()
Dim nState As Long
Dim sMode As String
If Application.Calculation = xlCalculationManual Then
Application.Calculation = xlCalculationAutomatic
nState = msoButtonUp
sMode = "Automatic"
Else: Application.Calculation = xlCalculationManual
Application.CalculateBeforeSave = False
nState = msoButtonDown
sMode = "Manual"
End If
With Application.CommandBars.ActionControl
.State = nState
.TooltipText = "Calculation mode is " & sMode
End With
End Sub
Private Sub Workbook_Open()
With Application.CommandBars("Standard")
With .Controls("Calculation Mode")
If .State = msoButtonUp Then
Application.Calculation = xlCalculationAutomatic
Else
Application.Calculation = xlCalculationManual
End If
End With
End With
End Sub
allowing me to toggle the calculation mode from automatic to manual. As I
explained in another thread I was having a problem when exiting excel with
the toggle button in manual mode..when I reopened excel the button would be
in manual mode (as it should be), but the calculation mode would be in
automatic.
I was able to fix that by adding a Workbook_Open subroutine to initialize
the button and calc mode. I put this sub under "This Workbook" in
personal.xls. I've included both macros below.
When I open up excel now, without directly opening up a file, no
problems..everything works great. The problem I have now is when I open up
excel by executing an actual excel file. When this happens the initialize
macro screws up because it seems to run before an actual workbook is opened.
The initialization macro will not work without an acual workbook open
because the calculation mode can't be set without a workbook being open.
Hopefully I've explained my problem well enough for you guys to understand.
Does anyone have any suggestions?
Thanks again.
Sub CalcMode()
Dim nState As Long
Dim sMode As String
If Application.Calculation = xlCalculationManual Then
Application.Calculation = xlCalculationAutomatic
nState = msoButtonUp
sMode = "Automatic"
Else: Application.Calculation = xlCalculationManual
Application.CalculateBeforeSave = False
nState = msoButtonDown
sMode = "Manual"
End If
With Application.CommandBars.ActionControl
.State = nState
.TooltipText = "Calculation mode is " & sMode
End With
End Sub
Private Sub Workbook_Open()
With Application.CommandBars("Standard")
With .Controls("Calculation Mode")
If .State = msoButtonUp Then
Application.Calculation = xlCalculationAutomatic
Else
Application.Calculation = xlCalculationManual
End If
End With
End With
End Sub