Reputation: 1
I trying to generate files with time stamp when I'm running test with multiple inputs(parameterisation).
Please suggest me how to add timestamp to filename
ex: C:\xxx\xxxx\xxx\Responses\xxx.xlsx
to this path I need to append timestamp to make file unique .
Upvotes: -1
Views: 2455
Reputation: 4356
Easy option:
Dim sTimeStamp, sPath
sPath = "C:\Path\To\My\Folder\myFile.xlsx"
' Get current time and date value and strip out the separators
sTimeStamp = Replace(Replace(Replace(Now, " ", "_"), "/", ""), ":", "")
'insert timestamp into file name
sPath = Replace(sPath, ".xlsx", "_" & sTimeStamp & ".xlsx")
Debug.Write sPath ' output is C:\Path\To\My\Folder\myFile_20112017_015827.xlsx
Upvotes: 0