LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default Excel won't open CSV file

I've got a CSV file to which I need to add a header line. I wrote a
little VB Script to do this. Once I ran it the size of the file
literally doubled. The header line is there now, however. When I open
the file in Excel, however, all the text in each line opens in one
cell. It's quite annoying. Has anyone seen this before? Okay, maybe
not the exact problem, but maybe where Excel won't open a CSV
correctly? I'm thinking there must be some odd character or something
in it that causes this, but the file "looks" normal.

Thanks for any suggestions,
Jennifer

Just in case anyone is interested, this is the script does:

Dim DtlHdrDim FilePath
Dim DtlName
Dim FSO, Fil, TempFile, TempName
Dim sLine

Const ForReading = 1, ForWriting = 2, ForAppending = 8

FilePath = "\\hqimpact\mktdata\Extract\"
DtlName = FilePath & "SalesDtl.csv"
TempName = FilePath & "Temp.csv"

Set FSO = CreateObject("scripting.filesystemobject")

DtlHdr =
"parSalesHdrID,parSalesDetailID,Before,Quantity,Af ter,Promo,PromoBefore"
& _
"ItemPrice,PromoAfter,POSItem,UnitNumber,Deple ted"

Set Fil = FSO.OpenTextFile(DtlName, ForReading, False)
sLine = Fil.ReadLine

If sLine < DtlHdr Then
Set TempFile = FSO.CreateTextFile(TempName,ForWriting, True)
TempFile.WriteLine DtlHdr
Do Until Fil.AtEndOfStream
sLine = Fil.ReadLine
TempFile.WriteLine sLine
Loop

Fil.Close

FSO.CopyFile TempName, DtlName, True
TempFile.Close
FSO.DeleteFile TempName
End If

Set Fil = Nothing
Set FSO = Nothing

 
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 Outlook Attachments opening after several errors everytime cito_support Setting up and Configuration of Excel 2 March 13th 06 06:15 PM
Weird File Open/Save As Behavior [email protected] Excel Discussion (Misc queries) 0 December 9th 05 02:26 AM
Excel startup switches Randy Excel Discussion (Misc queries) 9 June 14th 05 10:27 PM
Why Excel file doesn't open by double click. Siraj Excel Discussion (Misc queries) 1 February 6th 05 01:58 PM
How Do I open an excel file without Excel Viewer support CocoriteBallGiants Excel Discussion (Misc queries) 2 February 4th 05 10:50 PM


All times are GMT +1. The time now is 08:20 PM.

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

About Us

"It's about Microsoft Excel"