Generating tags ...
Create an Excel macro to extract sheets as pdf with the name of the sheets
Progress
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:
- Open your Excel workbook.
- Press
Alt + F11
to open the VBA editor. - Insert a new module by clicking
Insert > Module
. - 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
- Close the VBA editor.
- Run the macro by pressing
Alt + F8
, selectingExportSheetsAsPDF
, and clickingRun
.
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.
Suggestions
AAAnonymous