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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

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