Is there anyway to have an event within the active workbook fire the associated procedure in an Add-In? This needs to happen without any code within the active workbook being used.
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Excel Add-In
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Excel Add-In
- This topic has 2 replies, 2 voices, and was last updated 14 years, 4 months ago.
Viewing 1 reply threadAuthorReplies-
WSscign
AskWoody LoungerDecember 12, 2010 at 10:47 pm #1258541Declare a new workbook variable in the add-in, but declare it using the WithEvents keyword. VBA will then allow you to select that variable from the object drop down at the top. However these can only be declared in object modules, e.g. sheet code, or class modules.
Write the appropriate event responses, then at runtime (perhaps trap the WorkBook_Open event of the Application object by this same method?) assign the active workbook to that variable. Events firing for that object will also trigger the event code for the associated variable.
For example, try adding the following code:
Code:Public WithEvents app As Application Public WithEvents wbk As Workbook Private Sub Workbook_Activate() Set app = Application End Sub Private Sub app_WorkbookActivate(ByVal Wb As Workbook) Set wbk = Wb Debug.Print "Activated: " & Wb.Name End Sub Private Sub app_SheetActivate(ByVal Sh As Object) Debug.Print "Application level: " & Sh.Parent.Name & " -> " & Sh.Name End Sub Private Sub wbk_SheetActivate(ByVal Sh As Object) Debug.Print "Workbook level: " & wbk.Name & " -> " & Sh.Name End Sub
A good resource to start from is this one.
-
Don Wells
AskWoody Lounger
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows 11 24H2 is broadly available
by
Alex5723
46 minutes ago -
Microsoft is killing Authenticator
by
Alex5723
58 minutes ago -
Downloads folder location
by
CWBillow
7 hours, 14 minutes ago -
Remove a User from Login screen
by
CWBillow
9 hours, 46 minutes ago -
TikTok fined €530 million for sending European user data to China
by
Nibbled To Death By Ducks
10 hours, 55 minutes ago -
Microsoft Speech Recognition Service Error Code 1002
by
stanhutchings
16 hours, 59 minutes ago -
Is it a bug or is it expected?
by
Susan Bradley
3 hours ago -
Image for Windows TBwinRE image not enough space on target location
by
bobolink
13 hours, 32 minutes ago -
Start menu jump lists for some apps might not work as expected on Windows 10
by
Susan Bradley
21 hours, 32 minutes ago -
Malicious Go Modules disk-wiping malware
by
Alex5723
11 hours, 8 minutes ago -
Multiple Partitions?
by
CWBillow
11 hours, 48 minutes ago -
World Passkey Day 2025
by
Alex5723
1 day, 5 hours ago -
Add serial device in Windows 11
by
Theodore Dawson
1 day, 20 hours ago -
Windows 11 users reportedly losing data due forced BitLocker encryption
by
Alex5723
20 minutes ago -
Cached credentials is not a new bug
by
Susan Bradley
2 days ago -
Win11 24H4 Slow!
by
Bob Bible
2 days, 1 hour ago -
Microsoft hiking XBox prices starting today due to Trump’s tariffs
by
Alex5723
1 day, 22 hours ago -
Asus adds “movement sensor” to their Graphics cards
by
n0ads
2 days, 3 hours ago -
‘Minority Report’ coming to NYC
by
Alex5723
1 day, 23 hours ago -
Apple notifies new victims of spyware attacks across the world
by
Alex5723
2 days, 11 hours ago -
Tracking content block list GONE in Firefox 138
by
Bob99
2 days, 11 hours ago -
How do I migrate Password Managers
by
Rush2112
1 day, 19 hours ago -
Orb : how fast is my Internet connection
by
Alex5723
1 day, 21 hours ago -
Solid color background slows Windows 7 login
by
Alex5723
2 days, 23 hours ago -
Windows 11, version 24H2 might not download via Windows Server Updates Services
by
Alex5723
2 days, 22 hours ago -
Security fixes for Firefox
by
Susan Bradley
1 hour, 13 minutes ago -
Notice on termination of services of LG Mobile Phone Software Updates
by
Alex5723
3 days, 10 hours ago -
Update your Apple Devices Wormable Zero-Click Remote Code Execution in AirPlay..
by
Alex5723
3 days, 19 hours ago -
Amazon denies it had plans to be clear about consumer tariff costs
by
Alex5723
3 days, 10 hours ago -
Return of the brain dead FF sidebar
by
EricB
2 days, 21 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.