Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Change to excel settings launching an event

Hi all,

I've got a simple custom command bar that does various useful stuff. One of
the things I'd like it to do is to have a button that controls the
application.calculation parameter. That bit is fine - the .faceid changes
depending on what the setting is so you can easily see what is on.

The problem is how to trap the event of application.calculation being
changed in a macro or in the options dialog, or just checking it at frequent
enough intervals without slowing the app down too much. I've exposed
application events in a class module of the toolbar add-in but something
seems to be wrong as sheetselectionchange and sheetchange don't seem to get
fired when the selection or sheets change. The code for the class module is
below, with the sub that doesn't work.

Thanks for any help

Jeff

Option Explicit
Public WithEvents xlApp As Application


Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target As
Range)
With CommandBars.FindControl(Tag:="cmdCalcChange")
Select Case Application.Calculation
Case xlCalculationAutomatic
.FaceId = 6735
.TooltipText = "Automatic calculation"
Case xlCalculationManual
.FaceId = 6743
.TooltipText = "Manual calculation"
Case xlCalculationSemiautomatic
.FaceId = 6751
.TooltipText = "Automatic calculation except tables"
End Select
End With
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Change to excel settings launching an event

Jeff,

Are you initialising application events? Do you have any code such as this
in ThisWorkbook

Dim AppClass As New Class1

Private Sub Workbook_Open()

Set AppClass.xlApp = Application

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jeff Standen" wrote in message
...
Hi all,

I've got a simple custom command bar that does various useful stuff. One

of
the things I'd like it to do is to have a button that controls the
application.calculation parameter. That bit is fine - the .faceid changes
depending on what the setting is so you can easily see what is on.

The problem is how to trap the event of application.calculation being
changed in a macro or in the options dialog, or just checking it at

frequent
enough intervals without slowing the app down too much. I've exposed
application events in a class module of the toolbar add-in but something
seems to be wrong as sheetselectionchange and sheetchange don't seem to

get
fired when the selection or sheets change. The code for the class module

is
below, with the sub that doesn't work.

Thanks for any help

Jeff

Option Explicit
Public WithEvents xlApp As Application


Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target As
Range)
With CommandBars.FindControl(Tag:="cmdCalcChange")
Select Case Application.Calculation
Case xlCalculationAutomatic
.FaceId = 6735
.TooltipText = "Automatic calculation"
Case xlCalculationManual
.FaceId = 6743
.TooltipText = "Manual calculation"
Case xlCalculationSemiautomatic
.FaceId = 6751
.TooltipText = "Automatic calculation except tables"
End Select
End With
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default Change to excel settings launching an event

It's alright, I sorted it by reopening the add-in. I guess it wasn't
initialised, even though the initialisation code was there already, as I
changed the class code. Dunno :)

Jeff

"Bob Phillips" wrote in message
...
Jeff,

Are you initialising application events? Do you have any code such as this
in ThisWorkbook

Dim AppClass As New Class1

Private Sub Workbook_Open()

Set AppClass.xlApp = Application

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Jeff Standen" wrote in message
...
Hi all,

I've got a simple custom command bar that does various useful stuff. One

of
the things I'd like it to do is to have a button that controls the
application.calculation parameter. That bit is fine - the .faceid

changes
depending on what the setting is so you can easily see what is on.

The problem is how to trap the event of application.calculation being
changed in a macro or in the options dialog, or just checking it at

frequent
enough intervals without slowing the app down too much. I've exposed
application events in a class module of the toolbar add-in but something
seems to be wrong as sheetselectionchange and sheetchange don't seem to

get
fired when the selection or sheets change. The code for the class module

is
below, with the sub that doesn't work.

Thanks for any help

Jeff

Option Explicit
Public WithEvents xlApp As Application


Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target

As
Range)
With CommandBars.FindControl(Tag:="cmdCalcChange")
Select Case Application.Calculation
Case xlCalculationAutomatic
.FaceId = 6735
.TooltipText = "Automatic calculation"
Case xlCalculationManual
.FaceId = 6743
.TooltipText = "Manual calculation"
Case xlCalculationSemiautomatic
.FaceId = 6751
.TooltipText = "Automatic calculation except tables"
End Select
End With
End Sub






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
How do I change settings to right-click to delete in Excel? LadyG Setting up and Configuration of Excel 1 February 5th 07 06:05 PM
Change Excel Defualt Settings Cillian Excel Discussion (Misc queries) 0 April 26th 06 05:14 PM
How do you change the excel number default settings? Garry Siskos Excel Discussion (Misc queries) 2 December 15th 05 10:47 PM
how can i change the default settings in excel 2003? bif Excel Discussion (Misc queries) 0 May 25th 05 02:24 PM
Change Excel Settings Ronbo Excel Discussion (Misc queries) 1 January 10th 05 09:29 PM


All times are GMT +1. The time now is 11:57 PM.

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"