Code Module Object

The CodeModule object contains all of the code for a single VBComponent (such as a Module, UserForm, Class Module, the Excel workbook, or an Excel sheet). There is only ever one CodeModule for a component—its methods and properties enable you to locate, identify, modify, and add lines of code to a project's components. There can be more than one procedure of the same name in a module, if they are Property procedures:

Dim msSelection As String

Property Get TheSelection() As String

TheSelection = msSelection End Property

Property Let TheSelection(NewString As String)

MsSelection = NewString End Property

Hence, to uniquely identify a procedure, you need to supply both its name (TheSelection in this example) and the type of procedure you're looking for (vbext_pk_Get for Property Get, vbext_pk_Let for Property Let, vbext_pk_Set for Property Set, or vbext_pk_Proc for Subs and Functions). The ProcOfLine property provides this information for a given line number—the name of the procedure is the return value of the function, and the type of procedure is returned in the variable you supply to its ProcKind argument. It is one of the few properties in the whole of Office 2007 that returns values by modifying the arguments passed to it.

The Parent and VBE properties are defined at the beginning of this section (the Parent of a CodeModule being the VBComponent).

Was this article helpful?

0 0
The Accidental Blogging Millionaires

The Accidental Blogging Millionaires

Get Inspired By The Most Popular Bloggers Online! If You Want To Skyrocket Your Success With Business And Improve Your Overall Life You Need To Have A Look At The Accidental Blogging Millionaires! Business can be a fight, particularly when you’re trying to establish one online and like all fights, to succeed you must find the winning techniques and apply them.

Get My Free Ebook

Post a comment