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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| Sub Enregistre_xls()
'
' Enregistre_xls Macro
' Copie les onglets vers un nouveau classeur et lance la boîte de dialogue enregister pdf
'
Application.EnableEvents = False
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'ne lance la macro que s'il y a plus de 7 feuilles
If ThisWorkbook.Sheets.Count > 7 Then
' Proposer un nom de fichier REC ou CP _ annéemoisjour _ nom professionnel
année = Year(Now())
mois = Month(Now())
If mois < 10 Then mois = "0" & Month(Now())
jour = Day(Now())
If jour < 10 Then jour = "0" & Day(Now())
professionnel = Sheets("Attest").Range("B7").Text
nomclient = Sheets("Attest").Range("D7").Text
If (Sheets("Attest").Range("A1").Text = "ATTESTATION DE RECEPTION PEB D'UN SYSTEME DE CHAUFFAGE") Or (Sheets("Attest").Range("A1").Text = "Attest van EPB-periodieke controle van een verwarmingsketel of een waterverwarmingstoestel") Then
sorte = "REC_"
Else
sorte = "CP_"
End If
nom_proposé = nomclient & " - " & sorte & jour & " " & mois & " " & année & "_" & professionnel
Nom_fichier = InputBox("Choisir le nom du fichier ?" & Chr(13) & "Bestandsnaam Ingeven ?", "", nom_proposé)
If Nom_fichier = "" Then Exit Sub
'Feuilles à sélectionner
Call montre_feuilles
Sheets("Attest").Select
For i = 1 To ThisWorkbook.Sheets.Count
nom = Sheets(i).Name
If (nom <> "Menu") And (nom <> "Attest_fr_long") And (nom <> "Mesures < 1 MW (0)") And (nom <> "Mesures >= 1 MW (0)") And (nom <> "Attest_nl_long") And (nom <> "Metingen < 1 MW (0)") And (nom <> "Metingen >= 1 MW (0)") Then Sheets(i).Select Replace:=False
Next i
Call cache_feuilles
ActiveWindow.SelectedSheets.Copy
'Save as PDF
Dim fichier As String
'Dim nom As String
'adaptez le nom de la feuille
With ActiveSheets
'nom = ActiveSheets.Range("D7").Text
fichier = "Nom_fichier.pdf"
'pensez a ecrire le chemin
rep = "Z:\Cascade\Gestion\Gestion\data\ &nomclient"
chemin = rep & "\" & Nom_fichier
'ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _chemin, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=chemin, From:=1, To:=2, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
'Application.Dialogs(xlDialogSaveAs).Show "C:\" & Nom_fichier
'ActiveWorkbook.Close
Call cache_feuilles
Sheets("Menu").Select
End If
Application.EnableEvents = True
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub |
Partager