LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to ignore embedded linefeed in CSV quoted text fields?

I have a CSV file where the text elements in quotes have embedded linefeeds

123,"12/08/2009","is a new{LF}line",""

where {LF} is an actual linefeed, char(10)

I can open it directly in Excel 2007, which ignores these line breaks.
However, the US m/d/y dates come out incorrectly because my locale uses d/m/y

But if I open it in VBA with a Text Query (to parse the m/d/y date formats)
it does not import into Excel correctly. The text columns have linefeeds
inserted that force a newline so the line is correct up to the LF then the
record continues on the next row, eg

123 08.12.2009 is a new
line

Is there some Querytable parameter I can use to tell Excel to ignore
linefeeds?


TIA

Patrick


<pre
Set qt = ActiveSheet.QueryTables.Add(Connection:="TEXT;" & sFileName,
Destination:=ActiveSheet.Range("A1"))
With qt
.Name = sName
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 65001 ' Unicode UTF-8, not Windows ANSI = 850
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = aDataTypes ' eg Array(1, 1, 1, 1, 2)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
DoEvents: qt.Delete ' remove querytable link when done importing

</pre
 
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
Excel 2003 I want text quoted and then the value of a cell followi tenchi Excel Worksheet Functions 2 June 12th 07 06:51 AM
Adding comment text - linefeed visible - why? What-A-Tool Excel Programming 2 November 30th 06 03:23 AM
How to produce comma-delimited and quoted text file from Excel? Roger Kenner Excel Discussion (Misc queries) 1 September 15th 05 07:19 PM
Linking Embedded Document Fields mae1778 Excel Discussion (Misc queries) 0 August 19th 05 04:59 PM
Sorting embedded fields - control box Cheryl[_2_] Excel Programming 0 May 6th 04 09:01 PM


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