Excel Macro : Convert Multiple Excel Files to PDF

How to convert multiple excel files to PDF using Excel VBA - This is one of the most asked question on any excel discussion forum.

Scenario:
In analytics industry, reports are generally generated in excel and powerpoint format. But companies generally prefer delivering them to clients in PDF format. A medium sized project requires conversion of hundreds of excel files to PDF.

Description:
It generates PDF files from workbooks in a folder automatically. And PDF files are saved in the folder where you wish them to be. (Code adapted from a post from Ron de Bruin)

Prerequisites:
MS Office Add-in: Save as PDF or XPS
If this add-in is not installed on your computer, download it from the Microsoft site : Download Add-In (If this link is not working, Google search on "Save as PDF or XPS MS Office' and you'll find the link working)

How to check if the add-in is installed?
Click on Office button, go to Save As button. If PDF or XPS is showing in the list, it means it is installed on your system.


Download the workbooks:
1. PDF conversion of the whole workbook
It creates a PDF file of the whole workbook from workbooks in a folder.

As shown above, define paths where excel files are stored and converted files to be saved. And then Hit "Run Macro" button. Download this workbook

2. PDF conversion of the selected worksheet
It creates a PDF file of the selected worksheet from the workbooks in a folder.


Download this workbook

3. PDF conversion of a particular range
It creates a PDF file of a particular range from the active worksheet from the workbooks in a folder. Download this workbook

4. PDF conversion of each sheet as a separate file
It creates a separate PDF file of each sheet from the active worksheet from the workbooks in a folder. Download this workbook

5. PDF conversion of each multiple selected sheets as a separate file
It creates a separate PDF file of each sheet from the multiple selected sheets from the workbooks in a folder. Download this workbook

6. PDF conversion of two selected sheets in a single file
It creates a single PDF file of two selected sheets from the workbooks in a folder.
 Download this workbook

7. PDF conversion of multiple selected sheets in a single file
It creates a single PDF file of multiple selected sheets from the workbooks in a folder. Download this workbook

How to use:
1. Open Excel . Press Alt + F11 to open the visual basic editor.
2. If you wish to make any changes in the code, select a module where code is placed

Q. How to create a PDF report of a particular range of the worksheet?
Sol : Download this workbookOpen it and press Alt + F11. 
Select a particular module and change a range in this code ActiveSheet.Range("A1:F50").Select

Excel Tutorials : 100 Excel Tutorials

Get Free Email Updates :
*Please confirm your email address by clicking on the link sent to your Email*

Related Posts:

13 Responses to "Excel Macro : Convert Multiple Excel Files to PDF"

  1. Thanks, very useful and helpful! Previously painful task was done in 5.63 seconds :)

    ReplyDelete
    Replies
    1. Thanks for stopping by. I'm glad you found it helpful!

      Delete
  2. HI thanks for the help

    ReplyDelete
  3. actually you only have to press Shift after clicking the first sheet to the last sheet then select pdf or xps tab to convert all sheets

    ReplyDelete
  4. Super Boss, Can you just send the code to save them in multiple pdf's instead under sheet names instead single pdf

    ReplyDelete
  5. Great work man. Thanks very much.

    I copied the code in different work book is that ok? (I will not say I wrote the code myself and will say took it from the internet)

    ReplyDelete
    Replies
    1. It's absolutely okay. I appreciated you asked me for permission!

      Delete
  6. converting excel to pdf file on pc online can be download on this very well website http://www.tagpdf.com/online/convert-excel-to-pdf/, this is a wonderful converting excel to pdf file online, and There are only three steps to converting excel to pdf file online easily.


    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. I have about 1200 excel files that need to be converted to pdf. All of my files are in separate folders in one parent folder. can you give me some pointers on how I might edit your code to search within subfolders? thank you

    ReplyDelete
    Replies
    1. nevermind I figured it out haha

      Delete
  9. Hi I need to do the procedure for converting range of sheets in a workbook for a list of many workbooks with different sheet ranges specified within those workbooks. (not all files within a directory) I am having a lot of trouble trying to alter your VBA code to get this done. I currently have a list of the files and a list of the sheet names associated with those files but can't figure out how to loop the code across each workbook and each sheet range.

    Thanks

    ReplyDelete

Next → ← Prev