print PDF and save pdf with cell information

STEEL010

Board Regular
Joined
Dec 29, 2017
Messages
76
Hi there,

can anyone help I'm stock here with a VBA problem (I think :rolleyes:)

see code below, what I want to do is that Cell H2 what contains =now() to be saved as file name.
but its not working, is this the correct way or is there another way???

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
"C:\user\documents" & Range("H2").Value = Now & "_" & "Pakbon" & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End Sub

Greetings,
STEEL010
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I have tried this format but it says not the name but its save under the name FALSE.pdf

" & Range("H2").Value = Format(Now() = "yymmdd.hhmm") & "_" & "Pakbon" & ".pdf" _

please help
 
Upvote 0
Try:
Code:
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        "C:\user\documents\" & Replace(Replace(Range("H2").Value, "/", "_"), ":", "_") & "_Pakbon.pdf", _
        Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=True
Please use CODE tags - click the # icon in the message editor.
 
Upvote 0

Forum statistics

Threads
1,215,155
Messages
6,123,332
Members
449,098
Latest member
thnirmitha

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