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
|
'Sélection de la feuille à exporter en fichier texte puis exportation
Sheets("lib.nom1").Select
ActiveWorkbook.SaveAs Filename:= _
"D:\Données\lib.nom1\fichier1_nomVariante.txt" _
, FileFormat:=xlText, CreateBackup:=False
' *****************************************
' ********* Ouverture du 2ème fichier ************
' *****************************************
ChDir _
"D:\Données\lib.nom2"
Workbooks.Open Filename:= _
"D:\Données\lib.nom2\avpf.xls" _
, UpdateLinks:=3
' Sauvegarde
ActiveWorkbook.Save
' Exportation du fichier texte
Sheets("lib.nom2").Select
ActiveWorkbook.SaveAs Filename:= _
"D:\Données\lib.nom2\nom2_nomVariante.txt" _
, FileFormat:=xlText, CreateBackup:=False
' Fermeture du fichier sans sauvegarde
ActiveWindow.Close
' Ouverture du fichier texte pour changer les virgules en points
ChDir _
"D:\Données\lib.nom2"
Workbooks.OpenText Filename:= _
"D:\Données\lib.nom2\nom2_nomVariante.txt" _
, Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=True _
, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1) _
, Array(2, 1))
Cells.Replace What:=",", Replacement:=".", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False
ActiveWorkbook.Save
'As Filename:= _
"D:\Données\lib.nom2\nom2_nomVariante.txt" _
, FileFormat:=xlText, CreateBackup:=False
' Fermeture du fichier texte
ActiveWindow.Close |
Partager