Capturing CommandBar Events in VB Add-Ins Louisiana

This code sample shows how to capture all the events from your command-bars in a Visual Basic Add-In using only one declared event handler.

Local Companies

Quasar Software Inc
504-485-5606
710 Weiblen Pl
New Orleans, LA
Ecad Inc
504-818-3091
824 Elmwood Park Blvd
New Orleans, LA
Creative Computer Solutions
225-925-3210
1651 Thibodeaux Ave
Baton Rouge, LA
Network Solution Providers
225-709-2591
5515 Superior Dr
Baton Rouge, LA
Cyrious Software
225-752-2867
12627 Jefferson Hwy
Baton Rouge, LA
VanillaSoft, Inc.
866-763-8826
1820 St. Charles Ave.
New Orleans, LA
Electronic Evidence Retrival LLC
504-483-0201
718 N Alexander St
New Orleans, LA
CMA Technology Solutions
225-927-9200
8180 YMCA Plaza DR
Baton Rouge, LA
Custom Accounting Solutions Inc
225-935-2202
2974 Fritchie Dr
Baton Rouge, LA
Bits Technical Corp
225-752-8899
14141 Airline Hwy
Baton Rouge, LA

provided by: 
Originally published at Internet.com


Author: Toby

It seems like all VBIDE.CommandBarEvents (Visual Basic Command Bar buttons) which you need to catch should be declared separately. For example, if you want to get particular event from Save button. You should do it something like this (And this example returns only one buttons click event):

This is written in VB help files

private withevents ce as CommandBarEvents ' Sub Test() Dim c as CommandBarControl set c = Application.VBE.CommandBars("Menu Bar").Controls(2) set ce = Application.VBE.Events.CommandBarEvents(c) End Sub ' private Sub ce_Click(byval CommandBarControl as Object, Handled as Boolean, CancelDefault as Boolean) ' Put event-handling code here End Sub '

So I made simple class for hooking these events. This class captures the events for every buttons click event.

How this works

This class ctlCmdEvent can act both as ParentClass and ChildClass.

SetEvents method collects all CommandBarControls and creates a new ChildClass for each control. This ChildClass is able to get its control event (Click). ChildClass directs the event back to ParentClass which rises event back to the first user object.
...

Read article at Internet.com site

Featured Local Company

VanillaSoft, Inc.

866-763-8826
1820 St. Charles Ave.
New Orleans, LA
http://www.vanillasoft.com

Regional Articles
- Capturing CommandBar Events in VB Add-Ins Abbeville LA
- Capturing CommandBar Events in VB Add-Ins Alexandria LA
- Capturing CommandBar Events in VB Add-Ins Baker LA
- Capturing CommandBar Events in VB Add-Ins Bastrop LA
- Capturing CommandBar Events in VB Add-Ins Baton Rouge LA
- Capturing CommandBar Events in VB Add-Ins Bogalusa LA
- Capturing CommandBar Events in VB Add-Ins Bossier City LA
- Capturing CommandBar Events in VB Add-Ins Breaux Bridge LA
- Capturing CommandBar Events in VB Add-Ins Carencro LA
- Capturing CommandBar Events in VB Add-Ins Chalmette LA
- Capturing CommandBar Events in VB Add-Ins Covington LA
- Capturing CommandBar Events in VB Add-Ins Crowley LA
- Capturing CommandBar Events in VB Add-Ins Denham Springs LA
- Capturing CommandBar Events in VB Add-Ins Deridder LA
- Capturing CommandBar Events in VB Add-Ins Eunice LA
- Capturing CommandBar Events in VB Add-Ins Franklinton LA
- Capturing CommandBar Events in VB Add-Ins Gonzales LA
- Capturing CommandBar Events in VB Add-Ins Gretna LA
- Capturing CommandBar Events in VB Add-Ins Hammond LA
- Capturing CommandBar Events in VB Add-Ins Harvey LA
- Capturing CommandBar Events in VB Add-Ins Haughton LA
- Capturing CommandBar Events in VB Add-Ins Houma LA
- Capturing CommandBar Events in VB Add-Ins Jennings LA
- Capturing CommandBar Events in VB Add-Ins Kenner LA
- Capturing CommandBar Events in VB Add-Ins La Place LA
- Capturing CommandBar Events in VB Add-Ins Lafayette LA
- Capturing CommandBar Events in VB Add-Ins Lake Charles LA
- Capturing CommandBar Events in VB Add-Ins Leesville LA
- Capturing CommandBar Events in VB Add-Ins Mandeville LA
- Capturing CommandBar Events in VB Add-Ins Marrero LA
- Capturing CommandBar Events in VB Add-Ins Metairie LA
- Capturing CommandBar Events in VB Add-Ins Minden LA
- Capturing CommandBar Events in VB Add-Ins Monroe LA
- Capturing CommandBar Events in VB Add-Ins Morgan City LA
- Capturing CommandBar Events in VB Add-Ins Natchitoches LA
- Capturing CommandBar Events in VB Add-Ins New Iberia LA
- Capturing CommandBar Events in VB Add-Ins New Orleans LA
- Capturing CommandBar Events in VB Add-Ins Opelousas LA
- Capturing CommandBar Events in VB Add-Ins Pineville LA
- Capturing CommandBar Events in VB Add-Ins Plaquemine LA
- Capturing CommandBar Events in VB Add-Ins Ponchatoula LA
- Capturing CommandBar Events in VB Add-Ins Prairieville LA
- Capturing CommandBar Events in VB Add-Ins Rayne LA
- Capturing CommandBar Events in VB Add-Ins Ruston LA
- Capturing CommandBar Events in VB Add-Ins Saint Martinville LA
- Capturing CommandBar Events in VB Add-Ins Shreveport LA
- Capturing CommandBar Events in VB Add-Ins Slidell LA
- Capturing CommandBar Events in VB Add-Ins Sulphur LA
- Capturing CommandBar Events in VB Add-Ins Thibodaux LA
- Capturing CommandBar Events in VB Add-Ins Ville Platte LA
- Capturing CommandBar Events in VB Add-Ins Walker LA
- Capturing CommandBar Events in VB Add-Ins West Monroe LA
- Capturing CommandBar Events in VB Add-Ins Westwego LA
- Capturing CommandBar Events in VB Add-Ins Zachary LA
Related Local Event
Annual Technical Conference & Exhibition (ATCE 2009)
Dates: 10/4/2009 - 10/7/2009
Location: Ernest N Morial Convention Center, New Orleans
New Orleans, LA
View Details

Topics: 
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML