Inserting Events Template
When I want to write event code in a Workbook, I Alt-F11 to open the VBE, Cntl-R to open the Project Explorer, arrow to the class module in which the code will go, and… Then, as far as I can tell, I have to use my mouse and the dropdowns at the top of the module to insert the Sub and End Sub lines.

I could just type them in, but I would to get the arguments just right or the VBE wouldn’t like it. It would be nice if the Insert > Procedure menu item had a provision for event code.

The best solution I could muster is to create text files that contain the code I want. I have two text files in my Office folder (\Program Files\Microsoft Office 2000\Office\ is the default folder for Insert > File) called SheetEvents.txt and WorkbookEvents.txt.

SheetEvents contains the Worksheet_Change and Workbook_SelectionChange events. WorkbookEvents contains Open, BeforeClose and BeforeSave. Those are the events I use most often. I thought about making a separate file for each event, but I decided to just put the most common ones in a file and delete anything I don’t need. Creating the text files was a simple copy and paste operation into Notepad after I used the dropdowns to get the events I wanted.
Billkamm:
I hate how when you select an item on the left it automatically inserts what it wants from the right.
For example when I create a new user form and I choose “UserForm” from the left dropdown it automatically inserts “UserForm_Click”. It would be nice if it would let me pick what I want from the right before inserting anything.
29 June 2005, 11:06 amAlex J:
MZ Tools 3.0 for VBA has two functions which might help. The Add Procedure function does not, afaik, add an event procedure, BUT the Code Template allows the user to define pre-defined code segments - and just for Dick, you can define a shortcut for each code segment.
29 June 2005, 11:21 amBTW, I find MZ Tools provides some really useful functions. wouldn’t code without it.
Dick Kusleika:
Bill: I agree. I’ve told Microsoft that their choice of default events is poor. I don’t know if they listened, though.
29 June 2005, 11:54 amDick Kusleika:
Alex: I used to have MZ Tools but had a problem that it caused. I don’t know why I never re-installed it, but I think I will.
29 June 2005, 12:58 pmJim Rech:
>> I have to use my mouse and the dropdowns at the top of the module
I don’t know if you’re looking for a keyboard shortcut, Dick, but Ctrl-F2 activates the left dropdown and a Tab will then take you to the right.
30 June 2005, 6:13 amDick Kusleika:
Jim: Hooray! That’s just what I wanted.
30 June 2005, 9:30 amJon Peltier:
Dick -
I can’t believe you’d add a whole layer of infrastructure (text files with event procedure stubs) just to avoid using the mouse. Though I’m glad Jim saved you from this.
- Jon
30 June 2005, 10:35 pmDick Kusleika:
You can’t? I miss the old TRS-80 days, I guess.
1 July 2005, 6:27 amJon Peltier:
Man, you gotta adapt to the times.
1 July 2005, 10:14 amdoco:
[quote]
I miss the old TRS-80 days, I guess.
Yeah, what a hoot it was: 128k and everything you did was a programming process. Kind of like crawling: you were forced to learn to walk; because you were soon leaving the top two inches of your forehead on the bottom of the coffee table…
3 July 2005, 8:06 am