Results 1 to 5 of 5

Thread: Invoice Creation
Thanks Thanks: 0 Likes Likes: 0

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

    Post Invoice Creation

    i want to making diffrent number invoice in my PC also want save pdf in my target folder
    i was trying to by your coding but it change mumber but not save pdf in target folder

    here that coading


    Sub NextInvoice()
    Range("B2").Value = Range("B2").Value + 1
    Range("B9:B18").ClearContents
    End Sub
    Sub SaveInvoiceAsPDFAndClear()
    Dim NewFN As Variant
    NewFN = "C:\Users\admin\Documents\invoice copy" & Range("B2").Value & ".pdf"
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN, _
    Quality:=xlQualityStandard, IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, OpenAfterPublish:=False
    Range("B2").Value = Range("B2").Value + 1
    Range("B9:B18").ClearContents
    End Sub

  2. #2
    Board Regular
    Join Date
    Mar 2015
    Posts
    3,912
    Post Thanks / Like
    Mentioned
    72 Post(s)
    Tagged
    7 Thread(s)

    Default Re: Invoice Creation

    Welcome to the forum

    I tested your code and it works fine
    - are you sure you are looking in the correct folder for it ? (ie did VBA save it in the that folder or somewhere else ?)

    The code below is identical to yours but it is broken up to show the path being built up which makes it clearer ...

    If the invoice number is 5017 then this saves Invoice Copy5017.pdf to C:\Users\admin\Documents
    Code:
    Sub SaveInvoiceAsPDFAndClear()
        Dim NewFN As String
    'path where PDF to be saved
        NewFN = "C:\Users\admin\Documents\"
    'next add the name of the invoice
        NewFN = NewFN & "invoice copy" & Range("B2").Value & ".pdf"
    'save the file
        ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN
    'increase number by 1 and clear old values
        Range("B2").Value = Range("B2").Value + 1
        Range("B9:B18").ClearContents
    Did you intend to save it there? or to save 5017.pdf to SUB-FOLDER Invoice Copy which would look like this
    Code:
    'path where PDF to be saved
        NewFN = "C:\Users\admin\Documents\Invoice Copy\"
    'next add the name of the invoice
        NewFN = NewFN & Range("B2").Value & ".pdf"
    End Sub
    Last edited by Yongle; Jun 23rd, 2019 at 05:51 AM.

  3. #3
    New Member
    Join Date
    Jun 2019
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Invoice Creation

    yes i get this you are very help full
    thank you

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

    Default Re: Invoice Creation

    its shows macro in saved pdf how can i remove

  5. #5
    Board Regular
    Join Date
    Mar 2015
    Posts
    3,912
    Post Thanks / Like
    Mentioned
    72 Post(s)
    Tagged
    7 Thread(s)

    Default Re: Invoice Creation

    I cannot replicate your problem It has never happened to me


    This is a guess!!
    Test to see if the problem goes away and then we can fix the range
    Code:
        ActiveSheet.Range("A1:E30").ExportAsFixedFormat Type:=xlTypePDF, Filename:=NewFN

    1. Did it work?

    2. Are you able to specify the invoice range - is it always the same?

    3. If range is not always the same ...
    - which columns are in the invoice ?
    - which column can VBA use to find the last row of the invoice ?
    (= which column always has a value the last row ?)

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
  •