Thread: Print to PDF
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default Print to PDF

Hello:

I have the following vba code from Ron de Bruin to print to PDF. However I
want the file name to be the date and the values from E.G. cell A3. Please
let me know how to do that.

Thanks.

Sub RDB_PDF_ActiveSheet_Pages()
'This example publish the first two pages of the ActiveSheet
'You can change the from and To to only publish the pages you want
Dim FilenameStr As String

If Dir(Environ("commonprogramfiles") & "\Microsoft Shared\OFFICE" _
& Format(Val(Application.Version), "00") & "\EXP_PDF.DLL") < "" Then

FilenameStr = Application.DefaultFilePath & "\" & _
Format(Now, "dd-mmm-yy h-mm-ss") & ".pdf"

ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=FilenameStr, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
From:=1, _
To:=1, _
OpenAfterPublish:=False
MsgBox "You can find the PDF file here : " & FilenameStr

Else
MsgBox "PDF add-in Not Installed"
End If
End Sub