ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can macro open daily generated files? (https://www.excelbanter.com/excel-programming/438630-how-can-macro-open-daily-generated-files.html)

Valdemar[_2_]

How can macro open daily generated files?
 
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

JLGWhiz[_2_]

How can macro open daily generated files?
 
Give this a try:

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


"Valdemar" wrote in message
...
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




JLGWhiz[_2_]

How can macro open daily generated files?
 
Try this corrected version:

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

The variable has to be concatenated into the string.

"Valdemar" wrote in message
...
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




Mike H

How can macro open daily generated files?
 
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.


"Valdemar" wrote:

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


Valdemar[_2_]

How can macro open daily generated files?
 
Hi Mike,

fantastic, it works and I am happy

Thanks a lot,

Valdemar

Mike H pÃ*Å¡e:

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.


"Valdemar" wrote:

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


Mike H

How can macro open daily generated files?
 
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.


"Valdemar" wrote:

Hi Mike,

fantastic, it works and I am happy

Thanks a lot,

Valdemar

Mike H pÃ*Å¡e:

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.


"Valdemar" wrote:

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



All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com