Save as A PDF

Rebecca Kowalski

New Member
Joined
Feb 16, 2016
Messages
31
Hi all,

Not sure why the below part of my macro isn't working. It should save the Active Sheet (Tab2) as a PDF document. To the file location notes and call it whatever is in the cells D5,E5,H5 (in Tab1) and then the date.....

:(

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="W:\BlahBlahBlah" & Range("D5")("E5")("H5").Value & Format(Date, "mmdd")
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=W:\BlahBlahBlah" &[d5]&[E5]&[H5]&format(Date,"mmdd"), _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
 
Upvote 0
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=W:\BlahBlahBlah" &[d5]&[E5]&[H5]&format(Date,"mmdd"), _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Almost....

Try this:

Rich (BB code):
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="W:\BlahBlahBlah\" &[d5]&[E5]&[H5]&" " & format(Date,"mmdd") & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
 
Upvote 0
Sadly for some reason that didn't work :( :confused:

I just copy and pasted your macro into my esisting macro and added the file save location, did I miss a step?
 
Upvote 0
Almost....

Try this:

Rich (BB code):
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="W:\BlahBlahBlah\" &[d5]&[E5]&[H5]&" " & format(Date,"mmdd") & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False



Sorry it did work but for some reason it saved my document at "0218" no idea where that came from?
 
Upvote 0
Sorry it did work but for some reason it saved my document at "0218" no idea where that came from?
Hmm, I only amended the code suggested by Mandeep, so I suspect there were actually bits missing. You get the date part as 0218 as that is the date in format mmdd as you have requested. If there was no other data in the filename is would suggest that D5, E5 and H5 were blank.

For a tested and (as far as I can tell) working version try this:

Code:
Sub ExportSheetAsPDF()
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "W:\BlahBlahBlah\" & [d5] & [E5] & [H5] & " " & Format(Date, "mmdd") & ".pdf", Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
            OpenAfterPublish:=False
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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