Thursday, February 7, 2013

How To Save each Sheet Of a Work Book as PDF File

Excel VBA Macro To Save Each Sheet in ThisWorkBook as a PDF File
'This Macro Prints Each sheet of Thisworkbook[i.e. The workbook in which you use this macro code].
'If you want to run this macro on any Active Work Book , Please edit as required.
Sub PrintMyWorkbook2Pdf()
Dim WB As Object
Dim WS As Worksheet
Dim MyFilePath As String
Dim PdfFileName As String
Dim PdfFilesFolder As String

On Error Resume Next

Set WB = ThisWorkbook
PdfFilesFolder = ThisWorkbook.Name & "_" & "PDFs"
MyFilePath = "C:\Documents and Settings\Administrator\My Documents\"

MkDir MyFilePath & PdfFilesFolder & "\"

PdfFileName = ActiveSheet.Name

For Each WS In WB.Sheets

WS.Activate

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _

FileName:=MyFilePath & PdfFilesFolder & "\" & ActiveSheet.Name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False

Next WS

End Sub

Note:

The Macro Replace the Previous Pdf Files with the Latest Files Every Time You Run 

Thanks,Tamatam

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. Please post your genuine Feedback or comments only related to this Blog Posts. Please do not post any Spam comments or Advertising kind of comments which will be Ignored.

Featured Post from this Blog

How to compare Current Snapshot Data with Previous Snapshot in Power BI

How to Dynamically compare two Snapshots Data in Power BI Scenario: Suppose, we have a sample Sales data, which is stored with Monthly Snaps...

Popular Posts from this Blog