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 123 | Next

Jim DeMarco

"Pro Excel 2007 VBA"

We are going correct that
error in our cXML class. Our private GetNewXMLData method is almost identical to that original
code. This was done this way to show the relationship of the standard code to the class code.
We can use the XPath property of the Range object to determine if our destination cell
(which is set when we instantiate our cXML object) already belongs to a mapping. If it
belongs to a mapping, we??™ll perform a data refresh using the XmlMaps collection; if not, we??™ll
import the data and create a new XML map. We are also going to validate the import using
the XlXmlImportResult data type as the return value of our XmlImport call.
The first thing we need to do is return the name of the destination range??™s map if it has
one. Add the following private function to the cXML class:
Private Function CurrentMapName() As String
Dim strReturn As String
On Error GoTo Err_Handle
If Me.HasMaps Then
strReturn = m_oRange.XPath.map.Name
Else
strReturn = ""
End If
Exit_Function:
CurrentMapName = strReturn
Exit Function
Err_Handle:
'not in a cell in the mapped table - treat as new mapping
strReturn = ""
Resume Exit_Function
End Function
This code first checks to see if the workbook has any XML maps. If it does, it returns the
map name for the class??™s destination range. If not, it returns an empty string. The error handler
is there in case the destination range is set to a location outside an XML-mapped area.
It returns an empty string in that case, and treats it like a new mapping.


Pages:
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135