Print to PDF

A

art

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
 
T

Trevor Williams

Change this line to include the cell reference

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

HTH

Trevor Williams
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top