PC Review


Reply
Thread Tools Rate Thread

I can't figure this out - please help

 
 
PO
Guest
Posts: n/a
 
      11th Apr 2007
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      11th Apr 2007
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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW TO 'BLINK' A FIGURE INSTEAD OFF BOLDING THE FIGURE Nad.Engoor Microsoft Excel Worksheet Functions 3 30th Dec 2008 03:04 PM
Word 2007 - cross reference to figure reproduces figure plus capti =?Utf-8?B?Qm9yaXM=?= Microsoft Word Document Management 2 7th Sep 2007 09:48 AM
how do I link the text about figure number to the figure caption? =?Utf-8?B?Y3J5c3RhbHhk?= Microsoft Word Document Management 1 3rd Apr 2006 06:58 PM
Format Figure Dollar to Text Figure Michael Chong Microsoft Excel Discussion 1 26th Oct 2004 11:42 AM
Auto Convert -figure to (figure) =?Utf-8?B?T25n?= Microsoft Word Document Management 5 3rd Jul 2004 02:13 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:28 AM.