Bonjour,
Je souhaite imprimer un tableur en PDF, le code que j'ai actuellement fonctionne mais le problème est que, le fichier PDF est beaucoup trop large .. Regardez la PJ, vous allez comprendre ..
Voici mon code :
Sub Enregistrer_PDF_et_ouvrir()
'Permet d'enregistrer la feuille 1 en PDF et de l'ouvrir
Dim i As Variant
Dim MonApplication As Object
Dim MonFichier As String
Dim OuvrirFichier As Variant
If MsgBox("Avez-vous bien changé l'indice du document ?", vbYesNo, "Demande de confirmation") = vbYes Then
With Sheets("Choix des matériels").PageSetup
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
i = "TSM - " & Sheets("Choix des matériels").Cells(14, 3) & " - " & Sheets("Choix des matériels").Cells(12, 3)
Sheets("Choix des matériels").ExportAsFixedFormat Type:=xlTypePDF, Filename:="E:\INSA - GCE\Projet méthode\Documents internes\Tableau de sélection de matériels\" & i & ".pdf"
Else
MsgBox ("Le fichier n'a pas été enregistré. Veuillez changer l'indice et recommencer l'opération.")
Exit Sub
End If
'Permet d'ouvrir le fichier qui vient d'être crée
Set MonApplication = CreateObject("Shell.Application")
i = "TSM - " & Cells(14, 3) & " - " & Cells(12, 3)
MonFichier = "E:\INSA - GCE\Projet méthode\Documents internes\Tableau de sélection de matériels\" & i & ".pdf"
MonApplication.Open (MonFichier)
OuvrirFichier = True
Set MonApplication = Nothing
End Sub