Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Print to PDF
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 "art" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Macro to hide rows with a certain cell empty then set print area and print | Excel Programming | |||
cell borders that I create dont show on print preview or print | Excel Discussion (Misc queries) | |||
Pivot Table macro to set print area and print details of drill down data | Excel Discussion (Misc queries) | |||
Active cell counting in particular print page (one sheet having different print area) | Excel Worksheet Functions | |||
Need Help w/ Print Macro to Print All Visible Sheets (including Charts) in a Workbook | Excel Programming |