Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Using Workbooks.OpenText to read a tab-delimited file into a worksheet

Scott,

You need to use the textqualifier property

Workbooks.OpenText Filename:=lFile, DataType:=xlDelimited, _
TextQualifier:=xlTextQualifierNone, Tab:=True

Dan E

"Scott Lyon" <scott.lyonNOSPAM_at__NOSPAMrapistan.comNOSPAM wrote in message ...
I've got a VBA application (in Excel 2002) that uses the Workbooks.OpenText
function to read in a tab-delimited text file.


However, I've just noticed a problem. It seems that if any of the "cells"
either start and end with double quotes ("), or contain two sets of double
quotes together (""), but only if the cell starts/ends with double-quotes as
well, then the data is not importing properly. In the case of the start/end
double quotes, it simply drops them. In the case of the duplicate double
quotes, it removes one.


I need to have this represent the data exactly as is (and not drop the
"extra" double quotes). Is there a way to do that, without changing what I'm
doing too much?


The line I actually use to import is as follows (where lFile is a string
containing the path and filename of the text file to be read):

Workbooks.OpenText Filename:=lFile, DataType:=xlDelimited, Tab:=True


To better explain, if, in the tab-delimited text file, there is a "cell"
that contains the following text:
"The quick brown fox jumped over the lazy dog"

it will import as:

The quick brown fox jumped over the lazy dog


Also, if a "cell" contains:
"It was a ""dark"" night"

then it will import as:
It was a "dark" night



Is there a parameter I can set in the OpenText function, to keep from Excel
trying to be too smart (and reducing the double-quotes)?


Thanks!
-Scott




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
How can I save a file as a comma-delimited text file in Excel? LAM Excel Discussion (Misc queries) 1 May 3rd 05 10:24 PM
Export excel file to semicolon delimited text file capitan Excel Discussion (Misc queries) 5 April 7th 05 03:06 AM
save excel file from a table delimited file (.txt) using macros sedamfo New Users to Excel 1 February 15th 05 04:19 AM
save an Excel worksheet as a comma delimited file? Trophy Man Excel Discussion (Misc queries) 2 January 8th 05 03:11 AM
OpenText bug ? Orlando Magalhães Filho Excel Programming 0 August 1st 03 04:14 AM


All times are GMT +1. The time now is 10:35 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"