Hallo Zusammen,
Die Programmierung mit VBA ist für mich völliges Neuland.
Daher bitte Ich euch mir weiterzuhelfen.
Ich will ein Programm schreiben, dass eine XLS-Datei in eine XML-Datein umwandelt. Das hat soweit auch ganz gut geklappt.
Nun will ich jedoch festlegen, dass nur Tags definiert werden, wenn die Felder in der Tabelle auch Text enthalten.
Open XMLFileName For Output As #1
Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) _
& "ISO-8859-1" & Chr(34) & "?>"
Print #1, "<IMPORT>"
Print #1, "<MAN_ID>1001</MAN_ID>"
If Not IsNull(RemoveAmpersands(FormChk(MyRow, MyCol))) Then
Campus = RemoveAmpersands(FormChk(MyRow, 1))
Building = RemoveAmpersands(FormChk(MyRow, 2))
Floor = RemoveAmpersands(FormChk(MyRow, 3))
Room = RemoveAmpersands(FormChk(MyRow, 4))
For MyRow = MyRng(RangeTwo, 1) To MyRng(RangeTwo, 2)
Print #1, "<CAMPUS>"
Print #1, "<NAME>" & RemoveAmpersands(FormChk(MyRow, 1)) & "</NAME>"
While InStr(1, RemoveAmpersands(FormChk(MyRow, 1)), Campus, vbTextCompare) <> 0
Print #1, "<BUILDING>"
Print #1, "<NAME>" & RemoveAmpersands(FormChk(MyRow, 2)); "</NAME>"
While InStr(1, RemoveAmpersands(FormChk(MyRow, 2)), Building, _
vbTextCompare) <> 0
Print #1, "<FLOOR>"
Print #1, "<NAME>" & RemoveAmpersands(FormChk(MyRow, 3)) & "</NAME>"
While InStr(1, RemoveAmpersands(FormChk(MyRow, 3)), Floor, _
vbTextCompare) <> 0
Print #1, "<ROOM>"
Print #1, "<NAME>" & RemoveAmpersands(FormChk(MyRow, 4)) & "</NAME>"
Print #1, "<DESCRIPTION>" & RemoveAmpersands(FormChk(MyRow, 4)) _
& "</DESCRIPTION>"
Print #1, "</ROOM>"
Wend
Print #1, "</FLOOR>"
Wend
Print #1, "</BUILDING>"
Wend
Print #1, "</CAMPUS>"
Next MyRow
Floor = RemoveAmpersands(FormChk(MyRow, 3))
Building = RemoveAmpersands(FormChk(MyRow, 2))
Campus = RemoveAmpersands(FormChk(MyRow, 1))
End If
Print #1, "</IMPORT>"
Close #1 Hier bekomme ich jedoch immer eine Fehlermeldung. Der Fehler muss in der Zeile "If Not IsNull(RemoveAmpersands(FormChk(MyRow, MyCol))) Then " liegen. Habe schon alles mögliche ausprobiert um den String mit RemoveAmpersands(FormChk(MyRow, MyCol)) mit einem Leerstring zu vergleichen, und nur dann das Programm auszuführen, es hat jedoch nichts geklappt.
Für Tipps zu meinem Fehler wäre ich sehr dankbar =)
Freundliche Grüße
Steffi |