1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Sub Gedcom()
Dim wbkGed As Excel.Workbook
' Ouverture d'un fichier Gedcom
Application.Workbooks.OpenText _
Filename:=nomCompletFichier, _
Origin:=65001, _
DataType:=xlDelimited, _
TextQualifier:=xlNone, _
FieldInfo:=Array(1, 2)
Set wbkGed = Application.ActiveWorkbook
' Commandes d'enregistrements qui ne conviennent pas
wbkGed.Save
' et
wbkGed.SaveAs _
Filename:=ged.FullName, _
FileFormat:=xlCSVUTF8
' et
wbkGed.SaveAs _
Filename:=ged.FullName, _
FileFormat:=xlCSVUTF8, _
Local:=True
' Enregistrement fonctionnel (mais lent)
Dim fUtf8avecBOM As ADODB.Stream
Dim g As Variant
Dim txt As String
Dim n°L As Long
Set fUtf8avecBOM = New Stream
fUtf8avecBOM.Charset = "utf-8"
fUtf8avecBOM.Mode = adModeReadWrite
fUtf8avecBOM.Type = adTypeText
fUtf8avecBOM.Open
g = wbkGed.Worksheets(1).Range("A1").CurrentRegion.Columns(1).Value
txt = ""
For n°L = 1 To UBound(g)
txt = txt & g(n°L, 1) & vbCrLf
Next n°L
fUtf8avecBOM.WriteText txt
fUtf8avecBOM.Flush
fUtf8avecBOM.SaveToFile nomCompletFichier, adSaveCreateOverWrite
fUtf8avecBOM.Close
Set fUtf8avecBOM = Nothing
End Sub |
Partager