LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default addin detect worksheet activation

I'm assuming you're speaking of an XLA add-in, not a COM or VSTO
add-in.

In the ThisWorkbook module of your XLA project, put in the lines

Private WithEvents App As Application

Private Sub Workbook_Open()
Set App = Application
End Sub

This creates an object named App of type Application that will trigger
all of the events of the application. Every Workbook and Worksheet
event has an Application level counterpart, so every event can be
trapped at the application level. The event that occurs when a user
moves from one sheet to another is the SheetActivate event, so use
code like the following. The Sh parameter is a Sheet object that
references the sheet to which the user just moved.

Private Sub App_SheetActivate(ByVal Sh As Object)
MsgBox "You just moved to:" & vbCrLf & _
"Workbook: " & Sh.Parent.Name & vbCrLf & _
"Worksheet: " & Sh.Name

End Sub


See www.cpearson.com/Excel/AppEvent.aspx for more information about
working with Application events.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)





On Fri, 20 Mar 2009 12:25:01 -0700, Bill Grigg
wrote:

All,

How can an addin detect that the user has clicked on a different sheet? Do I
have to somehow put code into the ActiveWorkbook?

Bill

 
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
Worksheet activation on Opening Workbook Raj[_2_] Excel Programming 2 February 20th 08 11:25 PM
Detect New Worksheet being added sharonm Excel Programming 3 September 26th 07 07:12 PM
Worksheet Activation from another workbook Ronbo Excel Programming 3 December 28th 05 09:39 PM
To detect changes in a worksheet Sinus Log Excel Programming 4 December 8th 05 07:43 AM
detect worksheet mike allen Excel Programming 2 October 28th 03 10:33 PM


All times are GMT +1. The time now is 12:38 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"