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.
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: