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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

MandeepBaluja

Board Regular
Joined
Jan 28, 2014
Messages
120
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=W:\BlahBlahBlah" &[d5]&[E5]&[H5]&format(Date,"mmdd"), _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
 

Fishboy

Well-known Member
Joined
Feb 13, 2015
Messages
4,267
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
 

Rebecca Kowalski

New Member
Joined
Feb 16, 2016
Messages
31
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?
 

Rebecca Kowalski

New Member
Joined
Feb 16, 2016
Messages
31
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?
 

Fishboy

Well-known Member
Joined
Feb 13, 2015
Messages
4,267
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:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,493
Messages
5,837,673
Members
430,509
Latest member
steve85215

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
Top