(Solved) – how to convert à worksheets excel in to PDF


I am working on a VBA code in wich i try to convert a selected group of excels workcheets into PDF.
But the code don’t work.
The idea of the code is to convert only the selected sheets in which there names are diffetents from the followings sheet’s names

here’s the code.

Private Sub btnEnregistrer_Click()

Dim FolderPath As String

FolderPath = "C:UsersDesktopVBAtest"
Dim tabw() As Worksheet
Dim l As Integer
l = 1
Application.ScreenUpdating = False
On Error Resume Next
For l = 1 To Worksheets.Count '5 feuilles
If Worksheets(l).Name <> "Calcul" _
And Worksheets(l).Name <> "Formation" _
And Worksheets(l).Name <> "Entreprise" Then
Set tabw(l) = Worksheets(l)
l = l   1
End If

' Création fichier PDF
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & " test et controles des Resultats", _
openafterpublish:=False, ignoreprintareas:=False

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *