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

KeLiuyue
  • 8,149
  • 4
  • 25
  • 42
sarath
  • 1
  • 1

1 Answers1

0

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
Dave
  • 4,328
  • 2
  • 24
  • 33