How to add timestamp to filename in UFT when using writetofile property

2.3k views Asked by At

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 .

1

There are 1 answers

0
Dave On

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