PC Review


Reply
Thread Tools Rate Thread

addin detect worksheet activation

 
 
Bill Grigg
Guest
Posts: n/a
 
      20th Mar 2009
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
 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      20th Mar 2009
Option Explicit

Private WithEvents App As Application

Private Sub App_SheetActivate(ByVal Sh As Object)
'your code here
End Sub

Private Sub Workbook_Open()
Set App = Application
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

Bob

"Bill Grigg" <(E-Mail Removed)> wrote in message
news768605A-6DA8-45F2-865F-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      21st Mar 2009
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
<(E-Mail Removed)> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to detect if an addin is running Gee Weez Microsoft Excel Programming 1 8th Feb 2010 11:42 PM
Copying a Worksheet from an Addin =?Utf-8?B?VHJlZm9y?= Microsoft Excel Programming 8 25th Aug 2006 04:43 PM
Sorting an Addin Worksheet =?Utf-8?B?TVN3ZWV0RzIyMg==?= Microsoft Excel Programming 5 13th Jul 2006 02:26 PM
COM AddIn for IDE - how to detect host application... Heinz-Josef Bomanns Microsoft Outlook Program Addins 6 4th Dec 2004 06:49 AM
Office-Addin Detect currenty cursor position in Ms Word kids_pro Microsoft C# .NET 0 14th Aug 2004 02:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:08 AM.