SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 119 | Next

Jim DeMarco

"Pro Excel 2007 VBA"


Creating a module-level variable presents us with the option of accessing that variable
directly in our code. I??™m suggesting leaving it out to prevent that possibility.
Add the following code to the HasMaps property:
Public Property Get HasMaps() As Boolean
Dim blnReturn As Boolean
blnReturn = ActiveWorkbook.XmlMaps.Count >= 1
HasMaps = blnReturn
End Property
My preference is to keep my code as concise as possible without sacrificing readability.
I??™musing one line of code in place of an If...Else block. The long form, if you prefer it, looks
like this.
Dim blnReturn As Boolean
If ActiveWorkbook.XmlMaps.Count >= 1 Then
blnReturn = True
Else
blnReturn = False
End If
HasMaps = blnReturn
Add a property to store the name of the XML file to import plus a few additional setup
properties:
Public Property Get XMLSourceFile() As String
XMLSourceFile = m_sXMLSourceFile
End Property
CHAPTER 3 n USING XML IN EXCEL 2007 109
Public Property Let XMLSourceFile(newXMLSourceFile As String)
m_sXMLSourceFile = newXMLSourceFile
End Property
Public Property Get DataRange() As Excel.Range
Set DataRange = m_oRange
End Property
Public Property Set DataRange(newRange As Excel.Range)
Set m_oRange = newRange
End Property
Property Get Overwrite() As Boolean
Overwrite = m_blnOverwrite
End Property
Property Let Overwrite(newOverwrite As Boolean)
m_blnOverwrite = newOverwrite
End Property
Public Property Get MapName() As String
MapName = m_sMapName
End Property
We??™ve added a property to store and retrieve the DataRange into which we??™ll put our data
(remember, it??™s the top-left cell reference in the range).


Pages:
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131