It would be very easy for us to export the class module for use in someone
else??™s Excel project, or an Access database or even a Word document.
The key to successfully implementing classes is to keep the code as generic as possible.
Of course, if you are creating a class for one specific task, this is an acceptable exception to
the rule, but in general, keeping code generic provides great reuse opportunities.
Classes also provide an excellent example of self-documentation via IntelliSense.
Anytime you reference an object variable in your code and type the . operator, you??™ll see a
complete list of the object??™s functionality (just like the built-in VBA objects, such as ADO) as
shown in Figure 1-32.
Figure 1-32. Class objects provide documentation via IntelliSense.
CHAPTER 1 n THE MACRO RECORDER AND CODE MODULES 35
We will focus heavily on classes and object-oriented development as we move on in this
text. The ease of maintenance and high probability of reuse are well worth the extra planning
required to build applications using these techniques. Once you are comfortable with these
concepts, there really won??™t be much additional thought or planning required. It will be your
natural process to work in an OOP fashion.
UserForms
Excel provides us with UserForms as a means to provide a user interface (UI) to our Excel
applications. UserForms are similar to Access or Visual Basic forms. They are containers for
input and display controls. Both the forms and controls have properties, methods, and events
that we can code against.
Pages:
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62