Command
End Sub
Private Sub Class_Terminate()
Set m_cnn = Nothing
Set m_rs = Nothing
Set m_prm = Nothing
Set m_cmd = Nothing
End Sub
Let??™s take a look at both classes in their entirety (shown in Listings 2-7 and 2-8). Then
we??™ll create client code to use these objects and compare them to the original code in
Module1.
Listing 2-7. cExcelSetup Class Code
Option Explicit
Private m_xlSheet As Worksheet
Private m_rngInitialCellSelect As Range
Private m_rngDataRegionStart As Range
'
Public Property Get Worksheet() As Worksheet
Set Worksheet = m_xlSheet
End Property
Public Property Set Worksheet(newSheet As Worksheet)
Set m_xlSheet = newSheet
End Property
Public Property Get InitialCellSelection() As Range
Set InitialCellSelection = m_rngInitialCellSelect
End Property
CHAPTER 2 n DATA IN, DATA OUT 92
Public Property Set InitialCellSelection(newCell As Range)
Set m_rngInitialCellSelect = newCell
End Property
Public Property Get DataRegionStart() As Range
Set DataRegionStart = m_rngDataRegionStart
End Property
Public Property Set DataRegionStart(newCellAddress As Range)
Set m_rngDataRegionStart = newCellAddress
End Property
Public Sub SetKeyCells(InitialCell As Range, DataRegionStart As Range)
Set m_rngInitialCellSelect = InitialCell
Set m_rngDataRegionStart = DataRegionStart
End Sub
Public Sub SetupWorksheet()
Me.Worksheet.Activate
ClearRegion
Me.InitialCellSelection.Select
End Sub
Private Sub ClearRegion()
m_xlSheet.Activate
Me.
Pages:
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117