How can macro open daily generated files?

  • Thread starter Thread starter Valdemar
  • Start date Start date
V

Valdemar

Hi all,
please can anybody help me with xls macro? I receive on daily basis txt
files with name that contains actual date. Typically "Data_20100120.txt". I
want to use macro, open files, modify data and add them to another workbook.
That's no problem, but I don't know, how to daily open files with different
name (date).

I am not sure, how can I modify open sentence.....
Workbooks.OpenText Filename:="C:\Data_20100120.txt"
Many many thanks for your help.

Valdemar
 
Give this a try:

myDate = Format(Date, "yyyymmdd")
Workbooks.OpenText Filename:="C:\Data_myDate.txt"
 
Try this corrected version:

myDate = Format(Date, "yyyymmdd")
Workbooks.OpenText Filename:="C:\Data_" & myDate & ".txt"

The variable has to be concatenated into the string.
 
Hi,

Not tested but should work

Mydate = Format(Now, "yyyymmdd")
MyPath = "C:\Data_"
Workbooks.OpenText Filename:=MyPath & Mydate & ".txt"


--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
Glad i could help
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
Back
Top