Save Excel in pdf

This Exel VBA tip teaches you how to save a Excel sheet in Pdf file format. A Worksheet object has a method called ExportAsFixedFormat allows you to export a sheet in Pdf format and save the Pdf file in your local disk. This method has two arguments. The first one is the type of the output file format. To save the sheet in Pdf file, this value must be xlTypePDF. The second argument specifies the output file name or the name of the file that you save the Pdf file. This is the general form of the ExportAsFixedFormat method.

ExportAsFixedFormat Format-Type, FileName

The VBA code below exports the Sheet2 and its data in the current WorkBook and save it as products.pdf file in the current folder.

ActiveWorkbook.Worksheets("Sheet2").ExportAsFixedFormat xlTypePDF,"products.pdf"

If you want to export and save all sheets in current WorkBook to Pdf format, you will use this code instead:

ActiveWorkbook.ExportAsFixedFormat xlTypePDF, "products.pdf"

Posted by: Dara | post date: 11-04-2012 | Subject: VBA for MS Excel

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.