date and time in file name

steve111

Registered User.
Local time
Today, 20:29
Joined
Jan 30, 2014
Messages
429
hi,

I have a macro that sends a report to a folder in " my documents "
below is how the file name of the report is created
but I have discovered that if a need a paper trail it cannot do it as when I resend the report it just over write the old one. can a date and time be added to this code

Code:
   strFullPath = varFolder & "\" & "Invoice Number" & " " & [Invoice].[Form]![InvoiceNo] & ".pdf"

thanks
steve
 
Sure can do even time if you want to, just use the NOW function and a little bit of your imagination.
 
hi,

I did try this but got this error message

" the output to action was cancelled"
I used this code

Code:
 ' strFullPath = varFolder & "\" & "Ackowledgement number " & " " & Me.ID & " " & Now() & ".pdf"
steve
 
That's probably because Now() will generate something like 05/11/2015 09:50:34
So your file name will be

Ackowledgement number 12345 05/11/2015 09:50:34.pdf

Try saving any file with that as a file name ...

Remove all the spaces (for ease of finding and sorting the file when you later want to list them / email them reprint them...) and format Now() datetime to a acceptable file name format.

If you used Debug.Print strFullPath you would see the answer
 
hi
thanks

yes having tried to save a file like that would not work thanks.

now ok

strFullPath = varFolder & "\" & "Ackowledgement number " & Me.ID & " " & Format(date, "yyyy_mm_dd") & ".pdf"
steve
 
Good - glad to have pointed you in the right direction.
As I suggested you file naming with spaces will lead to issues later if you want to look them up or find them.
For your own sanity I would be tempted to store the document in a folder called Acknowledgements then simply call them ID & "_" & yyyy-mm-dd .pdf.

Later on if you have another document type store them in another appropriately named folder name with the same format and you can use simple code to retrieve them or check if they already exist.
 

Users who are viewing this thread

Back
Top Bottom