Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random bracketed number in file name [3].csv 1

Status
Not open for further replies.

darvistor

Technical User
Oct 2, 2007
33
US
Hello all,

I am having an issue with some vb code and importing data from a .csv file. I have a software program that we export a series of data out of every morning. When the first series of data is exported it is saved in the format of "query_export_results.csv". However, the next series of data that is exported has a random file name that looks like query_export_results[1].csv or query_export_results[3].csv, where the [number] randomly changes. I'm not sure what makes the bracketed number change, but I usually have to redo the export until the number changes to a [1] otherwise the following code will not work:


Code:
Windows("query_export_results[1].csv").Activate
Is there a way to activate this window and ignore the bracketed number? Does anyone know what may cause the bracketed number to appear or change? Temporary file maybe?

Any help would be appreciated.

Darv
 
Something like this ?
Code:
For Each w In Application.Windows
  If w.Parent.Name Like "query_export_results*.csv" Then
    w.Activate
    Exit For
  End If
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Awesome PHV! This works perfectly. You have no idea how happy you have made my group now as they wont spend so much time re-exporting data. Thanks!
 
The bracketed number may be changing from:
query_export_results[1].csv to
query_export_results[2].csv simply because

query_export_results[1].csv was already a "taken" file name so
query_export_results[2].csv is the next availble.

Before each import maybe you should remove the old files.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top