Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Event Procedures in an Add-In


Hi all

I am using the Workbook_SheetSelectionChange event to determine when
range is selected and to show the total, average and number of item
selected. This works great in a workbook, but I have tried to set thi
up in an add-in so it's availale all the time, but it doesn't wor
because the event is tied to the add-in file and not the currentl
active workbook.

Does anybody know of a way around this?

Thanks

DJ

--
DJ
-----------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...fo&userid=2122
View this thread: http://www.excelforum.com/showthread.php?threadid=46838

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Event Procedures in an Add-In

You could use an application event to monitor a selection change in any
workbook.

You could create a new workbook, save it as an addin (.xla) in your xlstart
folder. (Then it'll open each time excel starts.) Or you could merge it into
your personal.xl* workbook (if you have one).

This kind of code goes behind the ThisWorkbook module:

Option Explicit
Public WithEvents xlApp As Excel.Application
Private Sub Workbook_Open()
Set xlApp = Application
End Sub
Private Sub Workbook_Close()
Set xlApp = Nothing
End Sub
Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, _
ByVal Target As Range)
MsgBox Target.Cells.Count & " are selected"
End Sub

(I have no idea what your original code did, though.)

You can read a lot more about application events at Chip Pearson's site:
http://www.cpearson.com/excel/AppEvent.htm




DJB wrote:

Hi all

I am using the Workbook_SheetSelectionChange event to determine when a
range is selected and to show the total, average and number of items
selected. This works great in a workbook, but I have tried to set this
up in an add-in so it's availale all the time, but it doesn't work
because the event is tied to the add-in file and not the currently
active workbook.

Does anybody know of a way around this?

Thanks

DJB

--
DJB
------------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=468384


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Event Procedures in an Add-In

I have something similar that I keep in my personal.xla workbook.

But it's not based on the change of selection. I just assign a short cut key to
the macro and run it on demand.

I had some counts of formulas and other stuff that really slowed down when I did
selected all the cells on the sheet.



DJB wrote:

Hi all

I am using the Workbook_SheetSelectionChange event to determine when a
range is selected and to show the total, average and number of items
selected. This works great in a workbook, but I have tried to set this
up in an add-in so it's availale all the time, but it doesn't work
because the event is tied to the add-in file and not the currently
active workbook.

Does anybody know of a way around this?

Thanks

DJB

--
DJB
------------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...o&userid=21221
View this thread: http://www.excelforum.com/showthread...hreadid=468384


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Event Procedures in an Add-In


Dave

Ahhhhhh, I think I need the Public With Events... line. I'll have a g
with that. Thanks very much for the help.

DJ

--
DJ
-----------------------------------------------------------------------
DJB's Profile: http://www.excelforum.com/member.php...fo&userid=2122
View this thread: http://www.excelforum.com/showthread.php?threadid=46838

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
Event procedures for controls added with CreateEventProc John Austin[_6_] Excel Programming 7 March 24th 05 03:21 PM
learning event procedures R.VENKATARAMAN Excel Programming 4 January 21st 05 01:09 PM
Event procedures (and the temple of doom) Mark Tangard[_3_] Excel Programming 2 July 20th 04 04:45 PM
Event Procedures: Event on Worksheet to fire Event on another Worksheet Kathryn Excel Programming 2 April 7th 04 07:35 PM
Creating Event procedures from a macro Robert Stober Excel Programming 3 September 7th 03 06:52 PM


All times are GMT +1. The time now is 06:50 PM.

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

About Us

"It's about Microsoft Excel"