When exporting a datatable in UFT, how do you make the file name dynamic so that it dosent overwrite previous save?
Tags:
Question ID: 107335
1
0

I have code working to export a datatable to an excel file on my desktop but it seems that if ran again it will just continue to over write that file. Is there a way to make the file name dynamic so that each time I run the script an the excel file is saved to the desktop and dosent over write the previous file?

I was thinking about just having a date populate in the name…any ideas?

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on January 10, 2017 9:47 pm
134 views
Answers (1)
0
Private answer

One thing you could do is append a time/date stamp to the file name. This not only would make it unique, but also tell you when the file was created. For example, after setting your filename in a variable:

MyFilename = MyFilename + cstr(Now)

Note that the format of this date would be as m/dd/yyy HH:MM:SS AM/PM so you would need to format it in a file system compatible format and one that you like. For formatting of a date, see [this page at w3schools][1].

[1]: http://www.w3schools.com/asp/asp_ref_vbscript_functions.asp#date

Marked as spam
Posted by (Questions: 16, Answers: 807)
Answered on January 10, 2017 10:01 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top