Microsoft Excel Spreadsheets are commonly used to store financial data and prepare invoices. Often, you may need to convert the .xls or .xlsx files to .pdf format especially if you’re sending out invoices to your clients.
Microsoft Excel has a built-in option using which you can save your workbook, active sheet, or selected cells to a PDF file. This can be accomplished using the Save as… dropdown box.
By clicking on the More options… link, you can configure the page range, and the item to export (entire workbook, active sheet, etc) to PDF.
Pre-Windows 10 systems don’t have the Microsoft Print to PDF driver. As an alternative. you can use the free CutePDF Writer or Foxit PDF Printer (part of Foxit PDF Reader software.)
Bulk conversion of Excel sheets to PDF
However, if you have hundreds of invoices (in .xls or .xlsx format) that you need to batch/bulk convert the files into PDF, the above options are not ideal and take a long time.
- There are plenty of online portals that can bulk convert Excel sheets to PDF documents quickly without charging any fee. However, if your Excel sheets are confidential and you don’t want any intermediary portal or service to access them, then you may use the Excel to PDF offline conversion methods discussed in this article.
Fortunately, Microsoft Word and Microsoft Excel lets you automate the above task using scripting. This article tells you how to batch convert multiple Excel sheets into PDF files quickly.
How to Batch Convert Excel Sheets into PDF Files
Important: Before proceeding to any method below, please note that you’ll need to have Excel/Office installed and activated in your computer to convert the Excel sheet(s) to PDF.
Method 1: Using a custom VBScript
As said earlier, Microsoft Office has automation or scripting support. Using a VBScript, you can bulk convert Excel sheets to PDF quickly. Here is a simple script I wrote to do the job:
'Convert .xls or .xlsx to .pdf files via Send To menu Set fso = CreateObject("Scripting.FileSystemObject") For i= 0 To WScript.Arguments.Count -1 docPath = WScript.Arguments(i) docPath = fso.GetAbsolutePathName(docPath) If LCase(Right(docPath, 4)) = ".xls" Or LCase(Right(docPath, 5)) = ".xlsx" Then Set objExcel = CreateObject("Excel.Application") pdfPath = fso.GetParentFolderName(docPath) & "\" & _ fso.GetBaseName(docpath) & ".pdf" Set objWorkbook = objExcel.Workbooks.Open(docPath) objWorkbook.ExportAsFixedFormat 0, pdfPath, 0, True, False, , , False objWorkbook.Close False objExcel.Quit End If Next
Note: The above script exports the entire workbook (all sheets). Also, it ignores cells that are outside of the print area (in case you’ve set the print area for your sheets before). You can customize the output options by modifying the ExportAsFixedFormat command in line #12 of the above script as you wish.
Convert Excel sheets to PDF using VBScript
- Copy the above VBScript code to Notepad.
- Save the file with a .vbs extension, and in a permanent folder. — e.g.,
- Close Notepad.
- Open File Explorer and browse the following SendTo folder:
- Create a shortcut to the script
xls2pdf.vbsin the SendTo folder.
- Prefix the shortcut target with
wscript.exeand then followed by a space.
- Optionally, assign a nice-looking icon by clicking on the Change Icon button.
- Name the shortcut accordingly — e.g., Convert Excel Sheets to PDF
- Now, open the folder that contains the Excel sheets that you want to convert to PDF.
- Select the files, right-click on the selection, and click Send to.
- Click Convert Excel Sheets to PDF in the Send to menu.
That’s it! Your PDF files are now ready!
Method 2: Using File Converter (Freeware)
File Converter is a simple tool that allows you to convert or compress one or several files using the context menu in Explorer. This program is Freeware! You can download it from the following link:
After you install the software, all you need to do is select the .xls or .xlsx files you want to convert, click File Converter in the right-click menu and select To Pdf.
You’ll see the progress bar for each file, as seen below:
Note: We’ve covered the excellent File Converter software earlier on this website.
File Converter – Command-line
To convert a .xls or .xlsx file to .pdf using command-line using File Converter, use this syntax:
"C:\Program Files\File Converter\FileConverter.exe" --conversion-preset "To Pdf" "drive:\path\filename.xlsx"
Here is the list of the input and output formats supported by File Converter.
|Supported output formats||Compatible input formats|
|Audio||flac, aac, ogg, mp3, wav||3gp, aiff, ape, avi, bik, cda, flac, flv, m4a, mkv, mov, mp3, mp4, oga, ogg, wav, webm, wma, wmv|
|Video||webm, mkv, mp4, ogv, avi, gif||3gp, avi, bik, flv, gif, m4v, mkv, mp4, mpeg, mov, ogv, webm, wmv|
|Image||png, jpg, ico, webp||bmp, exr, ico, jpg, jpeg, png, psd, svg, tiff, tga, webp, pdf, doc*, docx*, odt*, odp*, ods*, ppt*, pptx*, xls*,
|Document||doc*, docx*, odt*, odp*, ods*, ppt*, pptx*, xls*, xlsx*, bmp, exr, ico, jpg, jpeg, png, psd, svg, tiff, tga|
* You need to have Microsoft Office installed and activated in order to convert Office documents.
This program, as well as the VBScript method, uses the Microsoft Office automation method to convert .xls/.xlsx to PDF files. This means that you’ll need to have Office installed and activated on your computer for the program to convert your Excel spreadsheets.
11 thoughts on “How to Batch Convert Excel Sheets into PDF Files”
the vbs script is brilliant, can you update it to save the files in a subdirectory?? such as
—-xls (excel files location)
—-pdf’s (save her)
I am trying not to learn vbs!!!! Have been dabbling in python so I kinda understand code
The code is broken somehow.. I was able to restore it, but all the ‘spaces’ come up as ‘unexpected characters’ when running the code..
i only figured it out by chance by pasting the code in excels VBA editor and the spaces came up as question marks, so by replacing them with spaces again the code ran.
works a treet now cheers!
@Joel: What version of Office/Excel do you use? Can you send me a sample excel sheet for testing? Does this issue occur when you use the ‘Save As PDF’ option in Excel?
Hi Ramesh. I don’t know if @Joel sent you a file or not. The thing is that, copying the code from this page and pasting it to Notepad (or Notepad++ for that matter) and then saving it as a “.vbs” file doesn´t work.
While pasting, incorrect characters (spaces, apostrophes, etc.) are saved. When trying to run the script it generates errors like:
=== Begin Error Message ====
Windows Script Host
Script: C:\Users\ADMIN\Documents\10 Stgo\scripts\ExcelToPDF.vbs
Error: Invalid character
Source: Microsoft VBScript compilation error
=== End Error Message ====
Replacing each of these incorrect characters makes the script work like a charm. (Using Office 365 as of 2021-10-25).
@Santiago: Saving it in ANSI (encoding) in your text editor should prevent this issue.
I have a question regarding the VB script. I have about 200 excel files that I need to bulk convert to PDF. The issue is that each excel file has 3 to 4 sheets each. However, I only need to send to PDF the first two. Normally I do this by opening the spreadsheet. Using CTRL to select sheet 1 called e-book and sheet 2 called Print. Then I click on File, Save as, browse to the folder and choose file type PDF. The fact that I’m doing this 500 times each quarter is getting tedious and time consuming and as I add more books even worse. Is there a way to modify the VB script code to do only select the first two sheet now matter how many are in the workbook itself? Thank you for any help you can give me. I’m a little new to this, so I hope you didn’t actually already answer this question in your example and I just didn’t realize it.
Simply fill in the missing arguments as stated in the linked Microsoft help:
ExportAsFixedFormat 0, pdfPath, 0, True, False, 777, 9999, False
will print pages 777 – 9999
Thank you very much!! Marvelous post.
Windows Script Host Error
I’m still getting the script error, I tried to delete and add the spaced back to the code. I can’t seem to get it to work. I can manually send the excel files to pdf. I found the other script that you posted for Word documents and it worked well. I can’t figure out why this one isn’t functioning. Any help would be greatly appreciated. I am trying to use this script to convert a large amount of excel files to pdf.
Much more interesting is the question: How can I create PDF files (automated) WITHOUT having Excel/Office installed? Is there any free solution to achieve this?