Sub mtf2xls()
Dim fs, a, strs, rets, langs(10)
Flag = 0
strs = InputBox("path to martif")
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(strs, 1, -2)
j = 0
Do While f.AtEndOfStream <> True
rets = f.ReadLine
lab1:
lgd = Len(rets)
If (Left(rets, 1) = " ") Then
lgk = lgd - 1
rets = Right(rets, lgk)
GoTo lab1
End If
If Left(rets, 10) = "<termEntry" Then
j = j + 1
Cells(j + 1, 1) = j
End If
wh = InStr(rets, "lang=")
If wh <> 0 Then
wh = wh + 5
asu = Asc(Mid(rets, wh, 1))
we = wh
recog2:
we = we + 1
If (Asc(Mid(rets, we, 1)) <> asu) Then
GoTo recog2
End If
lantx = Mid(rets, wh + 1, we - wh - 1)
If numlan = 0 Then GoTo addlan2
For k = 1 To numlan
If lantx = langs(k) Then GoTo knownlan2
Next k
addlan2:
numlan = numlan + 1
k = numlan
langs(k) = lantx
Cells(1, k + 1) = lantx
End If
knownlan2:
If Left(rets, 6) = "<term>" Then
lgd = Len(rets)
lgk = lgd - 13
ttr = Mid(rets, 7, lgk)
Cells(j + 1, k + 1) = ttr
End If
Loop
f.Close
Columns("A:K").AutoFit
End Sub
Wednesday, January 5, 2011
Excel macro for converting martif to xls
Labels:
Translation

