Results 1 to 9 of 9

Thread: Can anyone correct this Create PDF script?

  1. #1
    New Member
    Join Date
    May 2019
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Can anyone correct this Create PDF script?

    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

  2. #2
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    2,596
    Post Thanks / Like
    Mentioned
    33 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Can anyone correct this Create PDF script?

    .
    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

  3. #3
    Board Regular
    Join Date
    Sep 2004
    Posts
    1,317
    Post Thanks / Like
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can anyone correct this Create PDF script?

    What happens if you leave the comma out?
    From this
    Code:
    .Value, & ".pdf"
    to this
    Code:
    .Value & ".pdf"
    There are people who work a lot and make many mistakes. There are people who work a little and make few mistakes. I know people who don't make any mistakes.

  4. #4
    New Member
    Join Date
    May 2019
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can anyone correct this Create PDF script?

    Code:
    & ".pdf"
    was redundant and I removed it!!!

  5. #5
    New Member
    Join Date
    May 2019
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can anyone correct this Create PDF script?

    Thank you, I am going to try this one!!!

    iR

  6. #6
    New Member
    Join Date
    May 2019
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can anyone correct this Create PDF script?

    This worked perfectly.
    Thank you so much!

    iR

  7. #7
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    2,596
    Post Thanks / Like
    Mentioned
    33 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Can anyone correct this Create PDF script?

    You are welcome
    Glad to help.

  8. #8
    New Member
    Join Date
    May 2019
    Posts
    14
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can anyone correct this Create PDF script?

    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 by iRobert; May 16th, 2019 at 03:26 PM.

  9. #9
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    2,596
    Post Thanks / Like
    Mentioned
    33 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Can anyone correct this Create PDF script?

    Quote Originally Posted by iRobert View Post
    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", _

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •