Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Opening CSV files with VBA/macro

XL2000:
When a open this CSV file through EXCEL normal interface,
the files gets correctly formatted when it opens without
asking any questions. A date field present is interpreted
and formatted as dd-mm-yy.
If I record these actions and run then run the macro, the
file gets the wrong format in this "date field". It treats
the dates as mm-dd-yy! So half of the dates in the file do
not get recognized as dates (dates where day 12)
Again, this last behaviour only happens if you use the
macro to open it.

Glad to hear any help!

Vasco
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Opening CSV files with VBA/macro

Vasco,

use Workbooks.OpenText method..

and have a look at all the arguments in VBA help.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Vasco" wrote:

XL2000:
When a open this CSV file through EXCEL normal interface,
the files gets correctly formatted when it opens without
asking any questions. A date field present is interpreted
and formatted as dd-mm-yy.
If I record these actions and run then run the macro, the
file gets the wrong format in this "date field". It treats
the dates as mm-dd-yy! So half of the dates in the file do
not get recognized as dates (dates where day 12)
Again, this last behaviour only happens if you use the
macro to open it.

Glad to hear any help!

Vasco


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Opening CSV files with VBA/macro

Thanks

I was in the process of doing that but, unfortunately,
that does not work still! If i use the

FieldInfo:=Array(Array(1, xlDMYFormat)...) it will still
fail. It insists in reading MM/DD/YY instead of DD/MM/YY.

I must say that my date also have a time but i do not
think that should be a problem.

Again, only in VBA because if you do it through EXCEL it
will work. More complicated than it seems...

I can try to perform an online conversion using datavalue
and timevalue but is exquisite that you are not able to
duplicate a simple action in Excel with VBA.

Vasco



-----Original Message-----
Vasco,

use Workbooks.OpenText method..

and have a look at all the arguments in VBA help.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Vasco" wrote:

XL2000:
When a open this CSV file through EXCEL normal

interface,
the files gets correctly formatted when it opens

without
asking any questions. A date field present is

interpreted
and formatted as dd-mm-yy.
If I record these actions and run then run the macro,

the
file gets the wrong format in this "date field". It

treats
the dates as mm-dd-yy! So half of the dates in the file

do
not get recognized as dates (dates where day 12)
Again, this last behaviour only happens if you use the
macro to open it.

Glad to hear any help!

Vasco


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Opening CSV files with VBA/macro

My experience is that if the file has a .CSV extension, then the settings in
OpenText are ignored. (this may be improved in xl2002 - I can't say). The
way around this is to rename the file to .Txt and use OpenText with the date
column set to be interpreted as you wish. You can turn on the macro
recorder while you open it manually and choose the appropriate settings.
This will record the opentext method and define the appropriate settings.

--
Regards,
Tom Ogilvy

keepitcool wrote in message
...
Vasco,

use Workbooks.OpenText method..

and have a look at all the arguments in VBA help.



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Vasco" wrote:

XL2000:
When a open this CSV file through EXCEL normal interface,
the files gets correctly formatted when it opens without
asking any questions. A date field present is interpreted
and formatted as dd-mm-yy.
If I record these actions and run then run the macro, the
file gets the wrong format in this "date field". It treats
the dates as mm-dd-yy! So half of the dates in the file do
not get recognized as dates (dates where day 12)
Again, this last behaviour only happens if you use the
macro to open it.

Glad to hear any help!

Vasco




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening Files - Macro Max2073 Excel Worksheet Functions 1 December 10th 09 06:06 AM
Opening Files Using a Macro Mark Costello[_2_] Excel Discussion (Misc queries) 0 January 29th 08 03:48 PM
show most recent files first when opening excel files Anne` Excel Discussion (Misc queries) 5 January 23rd 08 01:54 AM
Macro for opening files that changes names [email protected] Excel Discussion (Misc queries) 1 May 12th 07 06:15 PM
Opening text files using macro Ron de Bruin Excel Programming 0 July 9th 03 02:49 PM


All times are GMT +1. The time now is 02:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"