Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PO PO is offline
external usenet poster
 
Posts: 66
Default I can't figure this out - please help

I'm using the following sub to import data from a textfile into excel.
Everything works fine except that all the columns in the textfile are merged
into one when inserted into Excel.

Text-file attributes:
=============
3 columns: Name, Address, Phone
TabDelimited
1st row contains rowheaders


Sub ImportData()
Dim cn As New ADODB.Connection

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\;" & _
"Extended Properties=""text;HDR=Yes;FMT=Delimited;"""

cn.Execute "SELECT * INTO [Newdata] IN 'C:\Data.xls' 'Excel 8.0;' FROM
Testdata.txt"

cn.Close

End Sub


1. How do I rewrite the code so the 3 columns in the text-file aren't merged
into column A in Excel?
2. Is it really necessary to use the schema.ini file or can it somehow be
avoided?



I also use a schema.ini file (in the same directory as the text-file):
============================================
[Testdata.txt]
ColNameHeader=True
Format=TabDelimited
MaxScanRows=0

TIA
PO


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default I can't figure this out - please help

Why not just turn on the macro recorder, then open the file using the
file=Open command and step through the Text import wizard, making the
appropriate choices. Then Turn off the macro recorder and look at the
recorded code. Alter to suit.

--
Regards,
Tom Ogilvy


"PO" wrote:

I'm using the following sub to import data from a textfile into excel.
Everything works fine except that all the columns in the textfile are merged
into one when inserted into Excel.

Text-file attributes:
=============
3 columns: Name, Address, Phone
TabDelimited
1st row contains rowheaders


Sub ImportData()
Dim cn As New ADODB.Connection

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\;" & _
"Extended Properties=""text;HDR=Yes;FMT=Delimited;"""

cn.Execute "SELECT * INTO [Newdata] IN 'C:\Data.xls' 'Excel 8.0;' FROM
Testdata.txt"

cn.Close

End Sub


1. How do I rewrite the code so the 3 columns in the text-file aren't merged
into column A in Excel?
2. Is it really necessary to use the schema.ini file or can it somehow be
avoided?



I also use a schema.ini file (in the same directory as the text-file):
============================================
[Testdata.txt]
ColNameHeader=True
Format=TabDelimited
MaxScanRows=0

TIA
PO



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
Can't figure this out... jmj713 Excel Discussion (Misc queries) 8 April 11th 09 02:33 AM
HOW TO 'BLINK' A FIGURE INSTEAD OFF BOLDING THE FIGURE Nad.Engoor Excel Worksheet Functions 3 December 30th 08 03:04 PM
Pg 98 - Figure 3-24 Help JimMay Excel Discussion (Misc queries) 2 June 10th 06 06:03 PM
Help, I can't figure this out sharpie23 Excel Programming 1 October 28th 05 03:10 PM
For Next help? I can't figure this out. DKY[_47_] Excel Programming 10 August 5th 05 08:43 PM


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

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"