Results 1 to 14 of 14

Thread: VBA how to use date to write file name in PDF

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Oct 2018
    Location
    Antwerp
    Posts
    41
    Location

    VBA how to use date to write file name in PDF

    How do I use "date document" for a PDF file name?
    The declaration of "document date" causes an error:

    Dim datedoc As Date
    Then I use datedoc to my PDF-file name which does not work.

    Sub InvoiceToPdf()
    Dim volgnr As Long
    Dim slo As String
    Dim Toganr As Long
    Dim bedrag As Currency
    Dim fname As String
    Dim datedoc As Date
    volgnr = Range("B1")
    slo = Range("B2")
    Toganr = Range("B3")
    bedrag = Range("B4")
    Path = "C:\Users\gebruiker\factuur"
    ' this works not, the datedoc causes error
    fname = Toganr & " - " & slo & " - " & volgnr & " - " & datedoc
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, ignoreprintareas:=False, Filename:=Path & fname
    End Sub
    ___________
    Thanks, Ward
    Last edited by Aussiebear; 06-26-2022 at 02:49 AM. Reason: Added code tags to supplied code

Posting Permissions

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