Can anyone correct this Create PDF script?

iRobert

New Member
Joined
May 15, 2019
Messages
14
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
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,093
.
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
 

jolivanes

Well-known Member
Joined
Sep 5, 2004
Messages
1,503
What happens if you leave the comma out?
From this
Code:
.Value, & ".pdf"
to this
Code:
.Value & ".pdf"
 

iRobert

New Member
Joined
May 15, 2019
Messages
14
Thank you, I am going to try this one!!!

iR
 

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,093
You are welcome
Glad to help.
 

iRobert

New Member
Joined
May 15, 2019
Messages
14
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:

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,093
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", _
 

Watch MrExcel Video

Forum statistics

Threads
1,095,726
Messages
5,446,153
Members
405,386
Latest member
xcookiemonster64

This Week's Hot Topics

Top