-1

当我使用多个输入(参数化)运行测试时,我试图生成带有时间戳的文件。

请建议我如何将时间戳添加到文件名 ex:C:\xxx\xxxx\xxx\Responses\xxx.xlsx到此路径我需要附加时间戳以使文件唯一。

4

1 回答 1

0

简单的选择:

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
于 2017-11-20T02:01:07.157 回答