Convert Multiple Sheets To Multiple PDF Files

How to concert multiple worksheets in an Excel workbook to multiple PDF files using VBA.

Convert Multiple Sheets To Multiple PDF Files

Here’s the complete VBA code to export each worksheet in an Excel workbook into individual PDF files:

Option Explicit

Sub ExportSheetsToPDFs()
Dim ws As Worksheet
Dim mywsname As String

For Each ws In Worksheets
ws.Select
mywsname = ws.Name
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=”C:\Users\takyar\Desktop\” & mywsname & “.pdf”, _
openafterpublish:=False

Next ws
End Sub