Save Excel As PDF With Excel VBA
Có thể bạn quan tâm
- Home
- Dashboards
- Excel Tips
- Tips & Tricks
- Charts
- Modelling
- Infographics
- VBA
- Shop Dashboards
- PowerPivot
- Power Pivot a User Guide
- Courses
- Excel Dashboard Course
- Advanced Dashboard Course
- Financial Modelling Course
- Excel VBA Course
- Blog
- About
Creating PDF Files with Excel VBA
Creating PDF files is a very useful tool as it allows you to put data in a format which cannot be altered. Creating this automatically is awesome. Adobe has created possibly the most widely used business application for PDF files. This can be downloaded free, Adobe Acrobat Reader. If you don’t already have it you will need reader to run this report. It can be downloaded free from the Adobe website. http://get.adobe.com/reader/ The following will print all of the visible worksheets within a workbook. If there are sheets which you do not wish included in the PDF file, I guess the easiest way to get around this would be to to hide the sheets you don’t want printed before you run the procedure.
Option Explicit Sub CreatePDF() 'Excel VBA to create PDF files. Dim str As String str="C:\Test\" ThisWorkbook.ExportAsFixedFormat xlTypePDF, str & "ReportA" & ".pdf" End SubTo use it change the file path remembering to include the back slash \ after your directory name. If you are using the below code to test workings then ensure you have a folder path called C:\Test\
The files is saved as ReportA however it maybe more flexible if you link the file name to a cell within the workbook.
Creating a Batch of PDF Files from ExcelThe following procedure will create a batch of reports and save them as PDF documents. One thing to remember is it will copy the first 3 sheets (change to suit) to PDF.
Sub PDFBatch() 'Excel VBA to bach some files to PDF (very useful). Dim i As Integer For i=2 To Range("A" & Rows.Count).End(xlUp).Row Sheet1.[a1]=Range("C" & i).Value Sheets(Array(1, 2, 3)).Select 'Change to suit ActiveSheet.ExportAsFixedFormat xlTypePDF, "D:\" & Range("A" & i).Value & ".pdf" Next i End SubThe above is very useful if you have lots of reports to push into PDF format. I will attach an example of the above to give the procedure context.
Từ khóa » Visual Basic Excel Save As Pdf
-
Save Excel As PDF With VBA
-
Excel VBA Save As PDF: Step-By-Step Guide And 10 Code ...
-
Excel Macro To Save Sheets As PDF - Contextures
-
Excel VBA Save As (Print) To PDF
-
Excel Macro To Save As PDF (5 Suitable Examples) - ExcelDemy
-
Save File As PDF In VBA (macro)? | MrExcel Message Board
-
VBA Save Sheet As PDF - YouTube
-
Save Excel File As PDF Using VBA (Entire Workbook Or ... - YouTube
-
Convert Excel To PDF Using VBA - The Only Guide You Will Need
-
How To Use Command Button To Save Active Worksheet As PDF File In ...
-
Export Docx To Pdf With Vba - Excel - Stack Overflow
-
Excel VBA SaveAs "Read-only" PDF File - Stack Overflow
-
Workbook.ExportAsFixedFormat Method (Excel) - Microsoft Docs
-
Excel VBA Save As PDF: Step-By-Step Guide And 10 ... - Pinterest