Table of contents
TOC
Collapse the table of content
Expand the table of content

CreateEventProc Method (VBA Add-In Object Model)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Creates an event procedure. Syntaxobject.CreateEventProc(eventname, objectname) As Long The CreateEventProc syntax has these parts:

PartDescription
objectRequired. An object expression that evaluates to an object in the Applies To list.
eventnameRequired. A string expression specifying the name of the event you want to add to themodule.
objectnameRequired. A string expression specifying the name of the object that is the source of the event.

Remarks Use the CreateEventProc method to create an event procedure. For example, to create an event procedure for the Click event of a Command Button control named Command1 you would use the following code, where CM represents an object of type CodeModule:

TextLocation = CM.CreateEventProc("Click", "Command1")

The CreateEventProc method returns the line at which the body of the event procedure starts. CreateEventProc fails if thearguments refer to a nonexistent event.

© 2018 Microsoft