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.
Code:
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