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 49 50 51 52 53 54 55 56
|
Sub ExportEcriture_FNP()
Dim Plage As Object, oL As Object, oC As Object
Dim Tmp$, Sep$, Ongl$
Dim Fichier$, Chemin$, CheminFiche$, Nlig&
Sheets(Range("PARAMETRES!Y13").Value).Select ' Non de l'onglet où se trouve les données à exporter
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlManual
End With
Fichier = Range("PARAMETRES!Y14").Value & "." & Range("PARAMETRES!Y15").Value ' 1ère colonne à exporter dernière colonne à exporter
'Fichier = "Fichier_Pv_syst" & ".csv"
Set rep = Application.FileDialog(msoFileDialogFolderPicker)
If rep.Show <> 0 Then
Chemin = rep.SelectedItems(1) & "\"
Else
MsgBox "Vous n'avez Choisi aucun Dossier", , "Manque de Choix de Dossier": Exit Sub
End If
Application.ScreenUpdating = False
CheminFiche = Chemin & Fichier
Nlig = Cells(Rows.Count, 1).End(xlUp).Row
Sep = vbTab ' ";"
Set Plage = Range(Range("PARAMETRES!Y16").Value & 4 & ":" & Range("PARAMETRES!Y17").Value & Nlig) '1ère ligne à exporter dernière ligne à exporter
Open CheminFiche For Output As #1
For Each oL In Plage.Rows
' écriture exportée
Tmp = ""
For Each oC In oL.Cells
Tmp = Tmp & CStr(oC.Text) & Sep
Next
Print #1, Left(Tmp, Len(Tmp) - 1)
Next
Close
Set Plage = Nothing
MsgBox "Le fichier CSV a est créé ", vbInformation, "Admin"
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
.EnableEvents = True
.Goto [A1], True
End With
End Sub |
Partager