Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Importing CSV just like Excel opening CSV


Fellow peeps

I have some CSV files exported from Requisite Pro.
When I just open them from Windows, they come in fine.

When I try to import them through VBA, the formatting is different and
my columns are screwed up.

Any ideas on exactly what parameters Excel uses during the opening of
a CSV so that I can set them programmatically?

Right now, I am using the Sheet.QueryTable method. I have played with
a bunch of the parameters with no luck. Is there another way to
import that emulates the way Excel does it from Windows?

Thanks much
Bob

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Importing CSV just like Excel opening CSV

Hi Bob,

Have you tried just opening the CSV file with Excel? Should import perfectly
if you do.

Regards,

OssieMac

"Bob" wrote:


Fellow peeps

I have some CSV files exported from Requisite Pro.
When I just open them from Windows, they come in fine.

When I try to import them through VBA, the formatting is different and
my columns are screwed up.

Any ideas on exactly what parameters Excel uses during the opening of
a CSV so that I can set them programmatically?

Right now, I am using the Sheet.QueryTable method. I have played with
a bunch of the parameters with no luck. Is there another way to
import that emulates the way Excel does it from Windows?

Thanks much
Bob


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Importing CSV just like Excel opening CSV

Re-reading you post I am now not certain that I properly understood what you
meant by opening from Windows. Did you mean that you were opening with Excel
or opening with another Windows program like the editor?

Anyway I normally import csv files by simply opening them with VBA and go
from there to import the data into other applications and they work fine.

Regards,

OssieMac



"OssieMac" wrote:

Hi Bob,

Have you tried just opening the CSV file with Excel? Should import perfectly
if you do.

Regards,

OssieMac

"Bob" wrote:


Fellow peeps

I have some CSV files exported from Requisite Pro.
When I just open them from Windows, they come in fine.

When I try to import them through VBA, the formatting is different and
my columns are screwed up.

Any ideas on exactly what parameters Excel uses during the opening of
a CSV so that I can set them programmatically?

Right now, I am using the Sheet.QueryTable method. I have played with
a bunch of the parameters with no luck. Is there another way to
import that emulates the way Excel does it from Windows?

Thanks much
Bob


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Importing CSV just like Excel opening CSV

Hi OssieMac
If I understand correctly, I think that Bob has a problem with the opening
of CSV files in Excel using VBA.
I too have encountered such problems with CSV file (semicolon delimiter) and
found non solution to date.
Although opening manually CSV files in Excel will work, it seems that both
methods Workbooks.Open and WorkBooks.OpenTextFile will fail through VBA ie:
it opens CSV file but it does NOT distribute data correctly into columns,
even when you set -in both VBA methods- the optionnal parameters correctly.

Cordially
Pascal

"OssieMac" a écrit dans le message de
news: ...
Re-reading you post I am now not certain that I properly understood what
you
meant by opening from Windows. Did you mean that you were opening with
Excel
or opening with another Windows program like the editor?

Anyway I normally import csv files by simply opening them with VBA and go
from there to import the data into other applications and they work fine.

Regards,

OssieMac



"OssieMac" wrote:

Hi Bob,

Have you tried just opening the CSV file with Excel? Should import
perfectly
if you do.

Regards,

OssieMac

"Bob" wrote:


Fellow peeps

I have some CSV files exported from Requisite Pro.
When I just open them from Windows, they come in fine.

When I try to import them through VBA, the formatting is different and
my columns are screwed up.

Any ideas on exactly what parameters Excel uses during the opening of
a CSV so that I can set them programmatically?

Right now, I am using the Sheet.QueryTable method. I have played with
a bunch of the parameters with no luck. Is there another way to
import that emulates the way Excel does it from Windows?

Thanks much
Bob




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Importing CSV just like Excel opening CSV

On Sep 18, 9:19 am, "papou" wrote:
Hi OssieMac
If I understand correctly, I think that Bob has a problem with the opening
of CSV files in Excel using VBA.



The above is correct. Forgetting VBA for a moment, if I see the CSV
in Windows Explorer, and open it using Excel, all is fine.

On the other hand, if I am writing VBA inside of an Excel document,
and tell Excel to import the same CSV using the Sheet.QueryTable
method (and various combinations of delimiter parameters), it does not
come in cleanly. I am discouraged by the fact that you may have dealt
with this and found no solution.

I guess at this point, I may try to programmatically open the CSV into
an independent spreadsheet (as if I did it through Windows), then copy
the sheet into the workbook where the VBA is running. Sounds like you
may have tried this but I am going to give it a shot since it won't
take too long.

Thanks
Bob



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Importing CSV just like Excel opening CSV

Hi Bob,

Here is an example of how I programmatically open csv files. They are opened
as an Excel workbook and I then extract the data from them. I am not aware of
any other method but am always interested in alternative methods.

Workbooks.OpenText Filename:="MyTextFile.csv", _
DataType:=xlDelimited, comma:=True

There is a mountain of info in Help if you search under 'OpenText Filename'
..It might even contain the info you need for the method you are experimenting
with.

Regards,

OssieMac


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
Importing Alan Beban's code on Arrays; Importing a module or a project Steve G Excel Worksheet Functions 4 August 27th 07 04:18 PM
REF errors when opening excel in xp. works fine when opening wor. br Excel Discussion (Misc queries) 6 September 13th 05 11:41 AM
importing into excel Tim V Excel Programming 0 July 13th 05 09:39 PM
excel VBA problem - setting workbook as variable & opening/re-opening safe Excel Programming 1 August 20th 04 12:22 AM
Excel importing of .csv and .xml Bernie Yaeger Excel Programming 2 July 28th 04 04:00 PM


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

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

About Us

"It's about Microsoft Excel"