AW: Daten aus tmp-Datei importieren
09.09.2008 21:37:00
Tino
Hallo,
Teste mal ob es so funktioniert.
Modul Modul1
Option Explicit
'Pfad zur Datei
Const strPFAD = "C:\Dokumente und Einstellungen\ts\Eigene Dateien\Forum\"
Sub XMLLesen()
Dim F As Integer
Dim sInhalt As String
Dim sFilename As String
Dim tempText() As String
Dim A As Long
'Datei Pfad + Name
sFilename = strPFAD & "Wolfgang.xml"
Application.ScreenUpdating = False
On Error GoTo Fehler:
'Überschrift
Range("A1") = "Vorname"
Range("B1") = "Nachname"
Range("A1:B2").Font.Bold = True
'Datei in String einlesen
F = FreeFile
Open sFilename For Binary As #F
sInhalt = Space$(LOF(F))
Get #F, , sInhalt
Close #F
'String aufteilen nach Vorname
tempText = Split(sInhalt, "MitarbeiterVorname"">")
For A = 1 To Ubound(tempText)
Cells(A + 1, 1) = Left$(tempText(A), InStr(tempText(A), "<") - 1)
Next A
Erase tempText
'String aufteilen nach Nachname
tempText = Split(sInhalt, "MitarbeiterNachname"">")
For A = 1 To Ubound(tempText)
Cells(A + 1, 2) = Left$(tempText(A), InStr(tempText(A), "<") - 1)
Next A
Erase tempText
Application.ScreenUpdating = True
Exit Sub
'Fehlerbeandlung
Fehler:
Application.ScreenUpdating = True
If Err.Number <> 0 Then MsgBox Err.Description, vbCritical, "Fehler"
On Error Resume Next
Close #F
End Sub
Gruß Tino
www.VBA-Excel.de