Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Adding .xla button for Toggle Calculation Button

I have a macro to toggle the calcuation button, but wish to convert it to an
..xla that I can share with my co-workers more easily. Does anyone know how to
do this so that the macro exists along with the button? I am not experienced
in this area.

Also, does anyone know how to improve the macro so that I can tell by the
button image if calc is on or off? Thanks much! Here is the macro below.
Sub ToggleApplicationCalculation()
If Application.Calculation = xlManual Then
Application.Calculation = xlAutomatic
MsgBox "Calculation toggled to Automatic."
Else
Application.Calculation = xlManual
Application.CalculateBeforeSave = True
MsgBox "Calculation toggled to Manual."
End If
End Sub 'ToggleApplicationCalculation



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Adding .xla button for Toggle Calculation Button

Build the button on add-in open

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0

With Application.CommandBars("Standard")
With .Controls.Add(temporary:=True)
.BeginGroup = True
.Style = msoButtonIcon
.FaceId = 283
.Caption = "CalculateToggle"
.OnAction = "ToggleApplicationCalculation"
End With
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a macro to toggle the calcuation button, but wish to convert it to

an
.xla that I can share with my co-workers more easily. Does anyone know how

to
do this so that the macro exists along with the button? I am not

experienced
in this area.

Also, does anyone know how to improve the macro so that I can tell by the
button image if calc is on or off? Thanks much! Here is the macro below.
Sub ToggleApplicationCalculation()
If Application.Calculation = xlManual Then
Application.Calculation = xlAutomatic
MsgBox "Calculation toggled to Automatic."
Else
Application.Calculation = xlManual
Application.CalculateBeforeSave = True
MsgBox "Calculation toggled to Manual."
End If
End Sub 'ToggleApplicationCalculation





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Adding .xla button for Toggle Calculation Button

I am having trouble to get this to work properly. It seems that I can add a
button by selection the add-in and some other items, but it seems like it
does not work consistently. Also, when I hardcode a breakpoint "stop" on the
workbookopen, it does not stop there. Any ideas? Thanks much!

"Bob Phillips" wrote:

Build the button on add-in open

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0

With Application.CommandBars("Standard")
With .Controls.Add(temporary:=True)
.BeginGroup = True
.Style = msoButtonIcon
.FaceId = 283
.Caption = "CalculateToggle"
.OnAction = "ToggleApplicationCalculation"
End With
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a macro to toggle the calcuation button, but wish to convert it to

an
.xla that I can share with my co-workers more easily. Does anyone know how

to
do this so that the macro exists along with the button? I am not

experienced
in this area.

Also, does anyone know how to improve the macro so that I can tell by the
button image if calc is on or off? Thanks much! Here is the macro below.
Sub ToggleApplicationCalculation()
If Application.Calculation = xlManual Then
Application.Calculation = xlAutomatic
MsgBox "Calculation toggled to Automatic."
Else
Application.Calculation = xlManual
Application.CalculateBeforeSave = True
MsgBox "Calculation toggled to Manual."
End If
End Sub 'ToggleApplicationCalculation






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Adding .xla button for Toggle Calculation Button

Did you follow the instructions on where to install it?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I am having trouble to get this to work properly. It seems that I can add

a
button by selection the add-in and some other items, but it seems like it
does not work consistently. Also, when I hardcode a breakpoint "stop" on

the
workbookopen, it does not stop there. Any ideas? Thanks much!

"Bob Phillips" wrote:

Build the button on add-in open

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0

With Application.CommandBars("Standard")
With .Controls.Add(temporary:=True)
.BeginGroup = True
.Style = msoButtonIcon
.FaceId = 283
.Caption = "CalculateToggle"
.OnAction = "ToggleApplicationCalculation"
End With
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a macro to toggle the calcuation button, but wish to convert it

to
an
.xla that I can share with my co-workers more easily. Does anyone know

how
to
do this so that the macro exists along with the button? I am not

experienced
in this area.

Also, does anyone know how to improve the macro so that I can tell by

the
button image if calc is on or off? Thanks much! Here is the macro

below.
Sub ToggleApplicationCalculation()
If Application.Calculation = xlManual Then
Application.Calculation = xlAutomatic
MsgBox "Calculation toggled to Automatic."
Else
Application.Calculation = xlManual
Application.CalculateBeforeSave = True
MsgBox "Calculation toggled to Manual."
End If
End Sub 'ToggleApplicationCalculation








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Adding .xla button for Toggle Calculation Button

I think I got it! I need to separate the procedures, and it worked! Thanks!

**** IN THE MODULE'S VBA ****
Sub ToggleApplicationCalculation()
On Error GoTo ErrorHandler
If Application.Calculation = xlManual Then
Application.Calculation = xlAutomatic
MsgBox "Calculation toggled to Automatic."
Else
Application.Calculation = xlManual
Application.CalculateBeforeSave = True
MsgBox "Calculation toggled to Manual."
End If
ErrorHandler:
End Sub 'ToggleApplicationCalculation


**** IN THISWORKBOOK'S VBA ****

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0

With Application.CommandBars("Standard")
With .Controls.Add(Temporary:=True)
.BeginGroup = True
.Style = msoButtonIcon
.FaceId = 283
.Caption = "CalculateToggle"
.OnAction = "ToggleApplicationCalculation"
End With
End With

End Sub



"Bob Phillips" wrote:

Did you follow the instructions on where to install it?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I am having trouble to get this to work properly. It seems that I can add

a
button by selection the add-in and some other items, but it seems like it
does not work consistently. Also, when I hardcode a breakpoint "stop" on

the
workbookopen, it does not stop there. Any ideas? Thanks much!

"Bob Phillips" wrote:

Build the button on add-in open

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0

With Application.CommandBars("Standard")
With .Controls.Add(temporary:=True)
.BeginGroup = True
.Style = msoButtonIcon
.FaceId = 283
.Caption = "CalculateToggle"
.OnAction = "ToggleApplicationCalculation"
End With
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a macro to toggle the calcuation button, but wish to convert it

to
an
.xla that I can share with my co-workers more easily. Does anyone know

how
to
do this so that the macro exists along with the button? I am not
experienced
in this area.

Also, does anyone know how to improve the macro so that I can tell by

the
button image if calc is on or off? Thanks much! Here is the macro

below.
Sub ToggleApplicationCalculation()
If Application.Calculation = xlManual Then
Application.Calculation = xlAutomatic
MsgBox "Calculation toggled to Automatic."
Else
Application.Calculation = xlManual
Application.CalculateBeforeSave = True
MsgBox "Calculation toggled to Manual."
End If
End Sub 'ToggleApplicationCalculation











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Adding .xla button for Toggle Calculation Button

Sorry, I made the assumption your code was in a standard code module. I'll
know better in future :-)

Bob


"Mike" wrote in message
...
I think I got it! I need to separate the procedures, and it worked!

Thanks!

**** IN THE MODULE'S VBA ****
Sub ToggleApplicationCalculation()
On Error GoTo ErrorHandler
If Application.Calculation = xlManual Then
Application.Calculation = xlAutomatic
MsgBox "Calculation toggled to Automatic."
Else
Application.Calculation = xlManual
Application.CalculateBeforeSave = True
MsgBox "Calculation toggled to Manual."
End If
ErrorHandler:
End Sub 'ToggleApplicationCalculation


**** IN THISWORKBOOK'S VBA ****

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0

With Application.CommandBars("Standard")
With .Controls.Add(Temporary:=True)
.BeginGroup = True
.Style = msoButtonIcon
.FaceId = 283
.Caption = "CalculateToggle"
.OnAction = "ToggleApplicationCalculation"
End With
End With

End Sub



"Bob Phillips" wrote:

Did you follow the instructions on where to install it?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I am having trouble to get this to work properly. It seems that I can

add
a
button by selection the add-in and some other items, but it seems like

it
does not work consistently. Also, when I hardcode a breakpoint "stop"

on
the
workbookopen, it does not stop there. Any ideas? Thanks much!

"Bob Phillips" wrote:

Build the button on add-in open

Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0
End Sub

Private Sub Workbook_Open()
On Error Resume Next
Application.CommandBars("Standard").Controls( _
"ToggleApplicationCalculation").Delete
On Error GoTo 0

With Application.CommandBars("Standard")
With .Controls.Add(temporary:=True)
.BeginGroup = True
.Style = msoButtonIcon
.FaceId = 283
.Caption = "CalculateToggle"
.OnAction = "ToggleApplicationCalculation"
End With
End With
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike" wrote in message
...
I have a macro to toggle the calcuation button, but wish to

convert it
to
an
.xla that I can share with my co-workers more easily. Does anyone

know
how
to
do this so that the macro exists along with the button? I am not
experienced
in this area.

Also, does anyone know how to improve the macro so that I can tell

by
the
button image if calc is on or off? Thanks much! Here is the macro

below.
Sub ToggleApplicationCalculation()
If Application.Calculation = xlManual Then
Application.Calculation = xlAutomatic
MsgBox "Calculation toggled to Automatic."
Else
Application.Calculation = xlManual
Application.CalculateBeforeSave = True
MsgBox "Calculation toggled to Manual."
End If
End Sub 'ToggleApplicationCalculation











Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle Button Squeaky Excel Worksheet Functions 0 September 17th 08 04:14 PM
Need to Use 1 Button to toggle On or Off Jim May Excel Discussion (Misc queries) 2 December 1st 07 08:01 PM
Toggle Button NavEx Excel Worksheet Functions 1 May 23rd 06 02:40 AM
Toggle Button Keri[_2_] Excel Programming 2 May 28th 04 04:58 PM
Toggle Button Ben E[_2_] Excel Programming 1 October 29th 03 04:42 PM


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"