ich moechte per VBA aus einer Tabelle eine XML-Datei erstellen.
In meiner Tabelle gibt es unter anderem 4 Spalten "int","string", "boolean" und "double".
Pro Datensatz steht immer nur in einer dieser 4 Spalten ein Wert.
Mein Code bisher sieht folgendermassen aus:
<pre>Sub XML_Export()
Dim Datei As String, Text As String
Dim lngRow, lngCol As Long
Dim varShow
Datei = ThisWorkbook.Path & "\Coordtable.xml"
Open Datei For Output As #1
Print #1, "<?xml version=""1.0"" encoding=""UTF-8"" standalone=""yes""?> "
Print #1, "<NamedTypedObjectCollection xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">"
For lngRow = 2 To ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Print #1, "<NamedTypedObject Name=""" & Cells(lngRow, 1) & """>"
Print #1, "<Type>" & Cells(lngRow, 2) & "</Type>"
Print #1, "<UserInput Name=""" & Cells(lngRow, 3) & """>"
Print #1, "<Expressionable>" & Cells(lngRow, 4) & "</Expressionable>"
Print #1, "<Category>" & Cells(lngRow, 5) & "</Category>"
Print #1, "<ReadOnly>" & Cells(lngRow, 6) & "</ReadOnly>"
Print #1, "<PropertyType>" & Cells(lngRow, 7) & "</PropertyType>"
Print #1, "<DefaultValue>" & Cells(lngRow, 8) & "</DefaultValue>"
Print #1, "<int>" & Cells(lngRow, 9) & "</int>"
Print #1, "<string>" & Cells(lngRow, 10) & "</string>"
Print #1, "<boolean>" & Cells(lngRow, 11) & "</boolean>"
Print #1, "<boolean>" & Cells(lngRow, 12) & "</double>"
Print #1, "</UserInput>"
Print #1, "</NamedTypedObject>"
Next lngRow
Print #1, "</daten>"
Close #1
End Sub</pre>
~f~
Bisher nimmt er alle Spalten mit - logisch, aber gibt es eine Moeglichkeit, dass nur die Zelle geschrieben wird, wenn sie auch ein Inhalt hat?
~f~
Print #1, "<int>" & Cells(lngRow, 9) & "</int>"
Print #1, "<string>" & Cells(lngRow, 10) & "</string>"
Print #1, "<boolean>" & Cells(lngRow, 11) & "</boolean>"
Print #1, "<boolean>" & Cells(lngRow, 12) & "</double>"
Danke und viele Gruesse
Rico