I’m using the following code to map elements to a list:
Sub GetDVA7()
Dim oMyMap As XmlMap
Dim strXPath As String
Dim oMyList As ListObject
Dim oMyNewColumn As ListColumn
'Add a schema map
ThisWorkbook.XmlMaps.Add (ThisWorkbook.Path & "\DVarchiveA2_replayInfo9.xsd")
' Idenfity the target schema map.
Set oMyMap = ThisWorkbook.XmlMaps("DVARCHIVE_Map")
Range("A1").Select
' Create a new list.
Set oMyList = ActiveSheet.ListObjects.Add
Set oMyNewColumn = oMyList.ListColumns(1)
' Specify the first element to map.
strXPath = "/DVARCHIVE/@ACCESS"
' Map the element.
oMyNewColumn.XPath.SetValue oMyMap, strXPath
' Add a column to the list.
Set oMyNewColumn = oMyList.ListColumns.Add
' Specify the next element to map.
strXPath = "/DVARCHIVE/@IP_PORT"
' Map the element.
oMyNewColumn.XPath.SetValue oMyMap, strXPath
End Sub
This is the schema:
<?xml version='1.0' encoding='UTF-16'?>
<!-- Created from XmlMap.Name: DVARCHIVE_Map -->
<!-- XmlMap.DataBinding.SourceUrl: C:\DVarchive_replayInfo.xml -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="DVARCHIVE">
<xsd:complexType>
<xsd:attribute name="ACCESS" type="xsd:string"/>
<xsd:attribute name="IP_PORT" type="xsd:integer"/>
</xsd:complexType>
</xsd:element>
</xsd:schema>
my code works fine for the first element: type="xsd:string" but for the second element: type="xsd:integer" I get a warning:
The data you are attempting to map contains formatting that is incompatible with the format specified in the worksheet.
(with three choices) "Use existing formatting," "Match element data type," or "Cancel."
I’m starting with a new blank sheet that is formatted by default to “General”.
If I map the integer element to the first column and the string element to the second column it works fine.
can someone tell me what causes the warning and how to fix it.
Using Excel 2007
Bookmarks