Macro to Create PDF with Current Date

byule

New Member
Joined
Oct 23, 2013
Messages
4
I'm pretty new to all this, but I was wondering if anyone could help with a macro. I'm trying to get it to create a PDF of my current worksheet with certain cells as the file name in a predetermined folder. For instance:

A1=Job
A2 = Dallas
A3 = Today()
Folder = /work

The PDF would be created in the /work folder as Job - Dallas - 10.23.2013

Any idea how I can do this?

byule
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Welcome to MrExcel.

If you record a macro while saving a pdf with that path and name manually what VBA code do you get?
 
Upvote 0
Sub PDF()
'
' PDF Macro
'
' Keyboard Shortcut: Ctrl+s
'
ChDir "M:\MAVERICK\Maverick Estimates\MUC-Emailed Files\Emailed Files 2013"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"M:\MAVERICK\Maverick Estimates\MUC-Emailed Files\Emailed Files 2013\Job - Dallas 10.23.13.pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End Sub
 
Upvote 0
OK try:

Code:
Sub PDF()
'
' PDF Macro
'
' Keyboard Shortcut: Ctrl+s
'
    ChDir "M:\MAVERICK\Maverick Estimates\MUC-Emailed Files\Emailed Files 2013"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "M:\MAVERICK\Maverick Estimates\MUC-Emailed Files\Emailed Files 2013\" & Range("A1").Value & " - " & Range("A2").Value & " - " & Format(Date, "mm.dd.yy") & ".pdf" _
        , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
        :=False, OpenAfterPublish:=True
End Sub

It's unusual to have dots in a file name.
 
Upvote 0

Forum statistics

Threads
1,216,150
Messages
6,129,154
Members
449,488
Latest member
qh017

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top