Can anyone correct this Create PDF script?

iRobert

New Member
Joined
May 15, 2019
Messages
28
Hello,
I have been fiddling with this script for hours:

Code:
Sub MakeInvoice_PDF() ' Make_PDF Macro from Invoice data in specific folder "\Invoicing\PDF Files\"
With ActiveSheet.PageSetup
    .Orientation = xlPortrait
    .PrintArea = "$A$1:$G$56"
End With


ActiveSheet.ExportAsFixedFormat, _
Type:=xlTypePDF, _
Filename:=ActiveWorkbook.Path & "\Invoicing\PDF Files\" & "Invoice" & "_" & Range("A8").Value & "_" & Range("A16").Value & "#" & Range("B13").Value & Range("C13").Value & "_" & Range("A18").Value, & ".pdf" _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub

but I get syntax errors!
Can anyone please help?

Thanks,
iR
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
.
Code:
Sub MakeInvoice_PDF()


Sheets("Sheet1").Range("A1:G56").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    ActiveWorkbook.Path & "\Invoicing\PDF Files\" & "Invoice_" & ActiveSheet.Range("A8").Value & "_" & ActiveSheet.Range("A16").Value & "_" & ActiveSheet.Range("B13").Value & ActiveSheet.Range("C13").Value & "_" & Range("A18").Value & ".pdf", _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
    OpenAfterPublish:=True




End Sub
 
Upvote 0
What happens if you leave the comma out?
From this
Code:
.Value, & ".pdf"
to this
Code:
.Value & ".pdf"
 
Upvote 0
Sorry me again....last thing.....
How would I add this in the directory path :
Invoice\Pdf Files\(value of cell A8)\
Would this be correct?:

Code:
Code:
ActiveWorkbook.Path & "\Invoicing\PDF Files\" & Range("A8").value & "\" & "Invoice_" & ActiveSheet.Range("A8").Value & "_" & ActiveSheet.Range("A16").Value & "_" & ActiveSheet.Range("B13").Value & ActiveSheet.Range("C13").Value & "_" & Range("A18").Value, _


Thanks,
iR
 
Last edited:
Upvote 0
Sorry me again....last thing.....
How would I add this in the directory path :
\Invoice\Pdf Files\(value of cell A8)\

Thanks,
iR

Hmmm ... you already have it there : ActiveWorkbook.Path & "\Invoicing\PDF Files" & "Invoice_" & ActiveSheet.Range("A8").Value &


Unless you mean :

Code:
ActiveWorkbook.Path & "\Invoicing\PDF Files\" &  ActiveSheet.Range("A8").Value & "\" & "Invoice_"  & "_" & ActiveSheet.Range("A16").Value & "_" & ActiveSheet.Range("B13").Value & ActiveSheet.Range("C13").Value & "_" & Range("A18").Value & ".pdf", _
 
Upvote 0

Forum statistics

Threads
1,224,743
Messages
6,180,686
Members
452,994
Latest member
Janick

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