Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Convert excel to different file format.

How do I save the excel file with both comma AND quotation delimited fields.
i am using Office 2003 SP1.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Convert excel to different file format.

Someone must be able to come up with a neater solution that this ... but I'll
post it anyway.

With a reference set to 'Microsoft Scripting Runtime', the following will
save the selected are as 'c:\myfile.csv' in the format you want.

There is surely a better way though!

Regards,

Chris.

Public Sub CSVQuote()

Dim fso As New FileSystemObject
Dim fsoTextStream As TextStream
Dim ranRow As Excel.Range
Dim ranCell As Excel.Range

Set fsoTextStream = fso.CreateTextFile("c:\myfile.csv", True)

For Each ranRow In Selection.Rows()

For Each ranCell In ranRow.Cells

If IsNumeric(ranCell) Or IsDate(ranCell) Then
fsoTextStream.Write ranCell
ElseIf IsEmpty(ranCell) Then
'Do nothing
Else
fsoTextStream.Write """" & ranCell & """"
End If

If ranCell.Column < ranRow.Column + ranRow.Columns.Count - 1 Then

fsoTextStream.Write ","

End If

Next ranCell

fsoTextStream.Write vbCrLf

Next ranRow

End Sub

--
Chris Marlow
MCSD.NET, Microsoft Office XP Master


"knothead" wrote:

How do I save the excel file with both comma AND quotation delimited fields.
i am using Office 2003 SP1.

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
Convert Excel XLS file to Quickbooks QIF file format Paul Excel Discussion (Misc queries) 0 October 22nd 07 10:46 PM
How do I convert an Excel 2003 file to ASCII format? Pat Excel Discussion (Misc queries) 1 January 20th 07 02:05 AM
Convert Excel spreadsheet to Ascii file format carley465 Excel Discussion (Misc queries) 2 December 5th 06 06:38 PM
I want to convert an Excel Chart to a .tif format file rlbell Charts and Charting in Excel 7 August 3rd 06 08:35 PM


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