AW: Kommentar einlesen
27.04.2009 12:15:27
Chris
Servus,
hier etwas ausführlicher:
Sub t()
Dim DatenArray, Index
DatenArray = Cells(1, 1).Comment.Text
Index = Split(DatenArray, Chr(10))
Dim Vorname As String, Nachname As String, Betreff As String, Datumvon As String, Datumbis As _
String, Uhrzeitab As String, Uhrzeitbis As String, Ort As String, Kommentar As String
For i = LBound(Index) To UBound(Index)
Select Case i
Case 1:
Dim Index1
Index1 = Split(Index(i), ",")
Vorname = Trim(Index1(0))
Nachname = Trim(Index1(1))
Case 2:
Dim Index2
Index2 = Split(Index(i), ":")
Betreff = Trim(Index2(1))
Case 3:
Dim Index3
Index3 = Split(Index(i), "von:")
Datumvon = Trim(Index3(1))
Case 4:
Dim Index4
Index4 = Split(Index(i), "bis:")
Datumbis = Trim(Index4(1))
Case 5:
Dim Index5
Index5 = Split(Index(i), "von:")
Uhrzeitab = Trim(Index5(1))
Case 6:
Dim Index6
Index6 = Split(Index(i), "bis:")
Uhrzeitbis = Trim(Index6(1))
Case 7:
Dim Index7
Index7 = Split(Index(i), ":")
Ort = Trim(Index7(1))
Case 8:
Dim Index8
Index8 = Split(Index(i), ":")
Kommentar = Trim(Index8(1))
Case Else
Kommentar = Kommentar & Chr(10) & Index(i)
End Select
Next i
MsgBox Vorname
MsgBox Nachname
MsgBox Betreff
MsgBox Datumvon
MsgBox Datumbis
MsgBox Uhrzeitab
MsgBox Uhrzeitbis
MsgBox Ort
MsgBox Kommentar
End Sub
Hierbei ist die erste Zeile des Kommentars eine Überschriftszeile, s. u..
Aufbau:
test:
Name, Vorname
Betreff: Urlaub
Datum von: 07.01.2009
Datum bis: 08.01.2009
Uhrzeit von: 13:30
Uhrzeit bis: 14:30
Ort: München
Kommentar:
test123
test567
Gruß
Chris