Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default *.csv format change if .xlt save as .csv in Excel 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default *.csv format change if .xlt save as .csv in Excel 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
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
Change Office 2007 delaut "save" format Bob Newman Excel Discussion (Misc queries) 1 October 21st 07 09:44 PM
How can I save excel files to a DBASE format in excel 2007? ukag2007 Excel Discussion (Misc queries) 4 June 22nd 07 01:31 PM
Save dbase IV and all oldest format with excel 2007 Miguel Jimenez Excel Discussion (Misc queries) 0 June 6th 07 10:36 PM
How to change 2006 calendar to 2007 and save dates in Excel Brent P. Excel Discussion (Misc queries) 2 December 27th 06 04:15 PM
How do you change the File save locations in Excel 2007? pglufkin Excel Discussion (Misc queries) 2 December 18th 06 07:22 PM


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