Generating tags ...

Create an Excel macro to extract sheets as pdf with the name of the sheets

Progress

5 steps completed!14.00 sec

Answer

Certainly! Below is an Excel VBA macro that will extract each sheet in the workbook as a PDF file with the name of the sheet:

  1. Open your Excel workbook.
  2. Press Alt + F11 to open the VBA editor.
  3. Insert a new module by clicking Insert > Module.
  4. Copy and paste the following code into the module:
Sub ExportSheetsAsPDF() Dim ws As Worksheet Dim filePath As String Dim fileName As String Dim fullPath As String ' Set the path to save the PDFs (modify as needed) filePath = ThisWorkbook.Path & "\" For Each ws In ThisWorkbook.Worksheets ' Create the full path and file name fileName = ws.Name & ".pdf" fullPath = filePath & fileName ' Export the sheet as a PDF ws.ExportAsFixedFormat Type:=xlTypePDF, Filename:=fullPath, Quality:=xlQualityStandard, _ IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False Next ws ' Notify user that sheets have been exported MsgBox "All sheets have been exported as PDFs to " & filePath, vbInformation End Sub
  1. Close the VBA editor.
  2. Run the macro by pressing Alt + F8, selecting ExportSheetsAsPDF, and clicking Run.

This macro will export each sheet in your Excel workbook as a separate PDF file with the name of the sheet, saved in the same directory as the workbook. Modify the filePath variable if you want to save the PDFs to a different directory.