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

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

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,261
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,261
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:

Watch MrExcel Video

Forum statistics

Threads
1,129,593
Messages
5,637,294
Members
416,963
Latest member
zazama

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