How to Save or Export Excel Chart as PDF

This post will guide you on how to save or export Excel charts as PDF using the move chart feature and VBA code. And we will provide you with the necessary steps to export multiple charts into a PDF file.

The move chart feature allows you to easily move charts to a new worksheet, which is useful when exporting multiple charts. Additionally, we will provide VBA code that automates the process of exporting multiple charts into a single PDF file.

Save one Chart to a PDF Page

You can save an Excel chart as a PDF page by following these steps:

Step1: Select the chart you want to save as a PDF.

How to Save or Export Excel Chart as PDF 1.png

Step2: Click on the “File” menu in Excel, then select “Save As“. the “Save As” dialog box will open. Choose the location where you want to save the PDF file. In the “Save as type” dropdown menu, select “PDF (*.pdf)”. Enter a name for the PDF file in the “File name” field.

How to Save or Export Excel Chart as PDF 21.png

Step3: Click on the “Options” button to open the “Options” dialog box.

How to Save or Export Excel Chart as PDF 3.png

Step4:  In the “Options” dialog box, choose the “Selected chart” option under the ” Publish What” section.

How to Save or Export Excel Chart as PDF 4.png

Step5: Click on the “OK” button to close the “Options” dialog box.

Step6: Click on the “Save” button to save the chart as a PDF file.

How to Save or Export Excel Chart as PDF 5.png

The resulting PDF file will contain only the selected chart and nothing else.

Export Multiple Charts into one PDF File using Move Chart

If you need to print several charts, it can be more efficient to print them all at once in one document rather than printing them separately.

Here are the steps to export multiple charts into one PDF file:

Step1: Select the first chart you want to export.

Step2: Right-click on one of the selected charts and choose “Move Chart“. The “Move Chart” dialog box will open.

export multiple excel charts as pdf 1.png

Step3: In the “Move Chart” dialog box, select the “New sheet” radio button and click “OK“.

export multiple excel charts as pdf 2.png

Step4: Repeat steps 1-3 for each chart you want to export.

export multiple excel charts as pdf 3.png

Step5: Select all of the charts by holding down the Ctrl key and clicking on each chart sheet tab that you want to export.

export multiple excel charts as pdf 4.png

Step6: Click on the “File” menu and choose “Save As“. Choose “PDF” as the file type in the “Save As” dialog box. Enter a name for the PDF file.

export multiple excel charts as pdf 5.png

Step7: In the “Save As” dialog box, choose the option “Active sheet” under “Publish what“. Click on the “OK” button to close the dialog box.

export multiple excel charts as pdf 6.png

Step8: Click on the “Save” button to save the PDF file.

export multiple excel charts as pdf 7.png

You can see that the last PDF file will contain one page for each chart you exported, with each chart on a separate page.

Export Multiple Charts into one PDF File with VBA Code

You can save or export multiple charts in the active workbook into one PDF file using VBA Code in Excel, and each chart is in a separate page. Just do the following steps:

Step1: Open your Excel workbook that contains the charts you want to export.

export multiple excel charts as pdf vba 1.png

Step2: Press “Alt + F11” to open the Microsoft VBA Editor.

Step3: In the VBA Editor, click “Insert” from the top menu, then choose “Module“.

Step4: In the new module, paste the below VBA code.

export multiple excel charts as pdf vba 2.png
Sub ExportAllChartsToPDF_excelgeek()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim co As ChartObject
    Dim exportSheet As Worksheet
    Dim chartCount As Integer
    Dim fileSaveName As Variant
    Dim chartWidth As Integer
    Dim chartHeight As Integer
    Dim chartTop As Integer
    Dim chartLeft As Integer
    
    ' Set a reference to the active workbook
    Set wb = ActiveWorkbook
    
    ' Create a new worksheet to export the charts
    Set exportSheet = wb.Worksheets.Add
 
    'Copy each chart to the export sheet
    For Each mySheet In wb.Worksheets
        For Each myChart In mySheet.ChartObjects
            chartCount = chartCount + 1
            If chartCount > 0 Then
                exportSheet.HPageBreaks.Add Before:=exportSheet.Cells(chartCount * 30, 1)
                'exportSheet.Cells(chartCount * 30, 1).Select
            End If
            myChart.Chart.ChartArea.Copy
            exportSheet.Paste Destination:=exportSheet.Cells(chartCount * 30 - 29, 1)
            
        Next myChart
    Next mySheet
    
    ' Check if any charts were exported
    If chartCount = 0 Then
        MsgBox "No charts found in workbook."
        exportSheet.Delete
        Exit Sub
    End If
    

    
    ' Export the export sheet as a PDF file
    fileSaveName = Application.GetSaveAsFilename(fileFilter:="PDF Files (*.pdf), *.pdf", Title:="Save PDF File")
    If fileSaveName <> False Then
        'exportSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=fileSaveName
        exportSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=fileSaveName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

    End If
    
    ' Delete the export sheet
    Application.DisplayAlerts = False
    exportSheet.Delete
    Application.DisplayAlerts = True
End Sub

Step5: Run the code by clicking the “Run” button or pressing “F5“. Or Press ALT + F8 to open the Macro dialog box or click on Macros command under Code group. Then select the macro named “ExportSelectedChartAsPicture_excelgeek” from the list of macros and click on “Run”.

export multiple excel charts as pdf vba 3.png

Step6: choose one location where you want to save the PDF file.

export multiple excel charts as pdf vba 4.png

Step7: The code will export all the charts in your workbook into one PDF file and save it to your specified location.

export multiple excel charts as pdf vba 5.png

Conclusion

Exporting charts as PDFs is useful when you need to share or print them. If you have multiple charts in your Excel document and want to export them as a single PDF file with each chart on a separate page, you can use the VBA code provided in this article.

Leave a Reply

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