Re : Export dans un fichier texte en conservant le format
Résolu avec un code peu élégant qui exporte, importe puis reexeporte le texte:
Private Sub Export_Citrix_Click()
Dim derniereligne As Integer, i As Integer
Dim j As Integer
Sheets("Export Citrix").Select
derniereligne = ActiveSheet.Range("F51").Value
Open "c:/export_citrix.csv" For Output As 1
For i = 1 To derniereligne
Print #1, Format(ActiveSheet.Cells(i, 1).Value, "dd/mm/yyyy"); ";"; _
ActiveSheet.Cells(i, 2).Value; ";"; _
ActiveSheet.Cells(i, 3).Value; ";"; Format(ActiveSheet.Cells(i, 4).Value, "0.0000"); _
";"; Format(ActiveSheet.Cells(i, 5).Value, "0.00")
Next
Close
Open "c:/export_citrix.csv" For Input As 1
i = 1
While Not EOF(1)
Line Input #1, a
'Copie des lignes dans excel
ActiveSheet.Cells(i, 8).Value = a
i = i + 1
Wend
Close
ActiveSheet.Columns("H:L").Select
Selection.Replace What:=".", Replacement:="/", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:=",", Replacement:=".", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Open "c:/export_citrix.csv" For Output As 1
For i = 1 To derniereligne
'valeur = Replace(ActiveSheet.Cells(i, 5).Value, ",", ".")
Print #1, ActiveSheet.Cells(i, 8).Value
Next
Close
End Sub
Fabien