PC Review


Reply
Thread Tools Rate Thread

*.csv format change if .xlt save as .csv in Excel 2007

 
 
Khayae
Guest
Posts: n/a
 
      14th Dec 2007
The previous programmer created an excel template file(.xlt) in lower version.

If we save this template file as [CSV (Comma delimited)(*.csv)] format in
(Excel 97-2003), the delimited comma will be until the last column that has
the data.

But if we save this template file as [CSV (Comma delimited)(*.csv)] format
in (Excel 2007), the delimited comma will be until the column at the end of
the sheet.

How can I do to be exactly the same as the lower versions (Excel 97-2003)?

Please see the attached files.

http://www.4shared.com/file/32023208/2dc0346d/Data.html

Thanking you in advance!

Khayae

 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      14th Dec 2007
if you want a macro solution I have posted this code many times before. It
works when Excel starts to do crazy things with CSV files like your problem.

Modify the 2nd and 3rd lines as required.

Sub WriteCSV()

Const MyPath = "C:\temp\"
Const WriteFileName = "text.csv"

Const Delimiter = ","

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

Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0


Set fswrite = CreateObject("Scripting.FileSystemObject")




'open files
WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)

LastRow = Cells(Rows.Count, "A").End(xlUp).Row

For RowCount = 1 To LastRow
LastCol = Cells(RowCount, Columns.Count).End(xlToLeft).Column
For ColCount = 1 To LastCol
If ColCount = 1 Then
OutputLine = Cells(RowCount, ColCount)
Else
OutputLine = OutputLine & Delimiter & Cells(RowCount, ColCount)
End If
Next ColCount
tswrite.writeline OutputLine
Next RowCount

tswrite.Close

Exit Sub
End Sub


"Khayae" wrote:

> The previous programmer created an excel template file(.xlt) in lower version.
>
> If we save this template file as [CSV (Comma delimited)(*.csv)] format in
> (Excel 97-2003), the delimited comma will be until the last column that has
> the data.
>
> But if we save this template file as [CSV (Comma delimited)(*.csv)] format
> in (Excel 2007), the delimited comma will be until the column at the end of
> the sheet.
>
> How can I do to be exactly the same as the lower versions (Excel 97-2003)?
>
> Please see the attached files.
>
> http://www.4shared.com/file/32023208/2dc0346d/Data.html
>
> Thanking you in advance!
>
> Khayae
>

 
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
set Excel 2007 as default to save files in Excel 2003 .xls format John UBS Microsoft Excel Setup 1 26th Mar 2010 02:53 PM
Excel 2007 save to PDF format Bob Microsoft Excel Crashes 0 31st Aug 2009 03:37 PM
Save as file format excel worksheet 4.0 in Microsoft excel 2007 Saria Microsoft Excel Misc 1 14th Jul 2008 11:39 AM
How do I save an excel file in dbaseIII format in Excel 2007 =?Utf-8?B?UCBCYW5uaXN0ZXI=?= Microsoft Excel Misc 1 6th Sep 2007 01:44 PM
How can I save excel files to a DBASE format in excel 2007? =?Utf-8?B?dWthZzIwMDc=?= Microsoft Excel Misc 4 22nd Jun 2007 01:31 PM


Features
 

Advertising
 

Newsgroups
 


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