Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save .csv file. Decimals separated by commas

Hi I've made a macro that save an excel file in .csv format.

I've several columns that have numeric format, with two decimal
separated by commas.

I don't have any problem when using Excel SaveAs Dialog.

But when I execute that action in the macro, I get decimals separate
BY POINT and not BY COMMA.

I include the final part of my macro:

' varText has the name of the file

columns("A:M").Select
ActiveWorkbook.SaveAs Filename:= _
"\\Mtdisa\directory\" + varText + ".csv" _
, FileFormat:=xlCSVMSDOS, CreateBackup:=False

Thanks for the attention. Regards

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Save .csv file. Decimals separated by commas

You should always include the Excel version you're using in a post.

VBA uses the English (American) settings when a macro is run. For the
SaveAs method you can have VBA use your local settings with the Local
parameter:

ActiveWorkbook.SaveAs Filename:= _
"c:\test", FileFormat:=xlCSVMSDOS, Local:=True

This is only available in Excel 2002 and later.

If you have an earlier version of Excel I think you have to use a macro.
Here's one I wrote sometime ago:

''Outputs the selection if more than one cell is selected, else entire sheet
Sub OutputActiveSheetAsCSVFile()
Dim SrcRg As Range
Dim CurrRow As Range
Dim CurrCell As Range
Dim CurrTextStr As String
Dim ListSep As String
Dim FName As Variant
FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")
If FName < False Then
ListSep = Application.International(xlListSeparator)
If Selection.Cells.Count 1 Then
Set SrcRg = Selection
Else
Set SrcRg = ActiveSheet.UsedRange
End If
Open FName For Output As #1
For Each CurrRow In SrcRg.Rows
CurrTextStr = ""
For Each CurrCell In CurrRow.Cells
CurrTextStr = CurrTextStr & CurrCell.Value & ListSep
Next
While Right(CurrTextStr, 1) = ListSep
CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
Wend
Print #1, CurrTextStr
Next
Close #1
End If
End Sub


--
Jim Rech
Excel MVP
"belitre " wrote in message
...
| Hi I've made a macro that save an excel file in .csv format.
|
| I've several columns that have numeric format, with two decimals
| separated by commas.
|
| I don't have any problem when using Excel SaveAs Dialog.
|
| But when I execute that action in the macro, I get decimals separated
| BY POINT and not BY COMMA.
|
| I include the final part of my macro:
|
| ' varText has the name of the file
|
| columns("A:M").Select
| ActiveWorkbook.SaveAs Filename:= _
| "\\Mtdisa\directory\" + varText + ".csv" _
| , FileFormat:=xlCSVMSDOS, CreateBackup:=False
|
| Thanks for the attention. Regards.
|
|
| ---
| Message posted from http://www.ExcelForum.com/
|


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Save .csv file. Decimals separated by commas

Thanks a lot. I'm using Excel 2000, so I should use a macro.

I've a really low knowledge of VBA. How could I use your macro?

I've to use a fixed directory to save the *.csv file.

Also I have the name of the file in a string variable, varText.

The selection is fixed too (Columns("A:M").Select) , so I think wha
I need must be very simple.

Any help would be much appreciated. Thanks again

--
Message posted from http://www.ExcelForum.com

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
Sort data separated by commas dab Excel Worksheet Functions 4 May 14th 10 12:53 AM
Compare two files and update data from another file base on words ina cell separated by commas mishak Excel Worksheet Functions 0 December 9th 09 01:35 AM
How do I de-concatenate items separated by commas! Taneli Hanhivaara Excel Discussion (Misc queries) 2 December 15th 08 11:45 AM
Help! I need a formula to add numbers separated by commas within SUPER EA Excel Worksheet Functions 8 July 27th 07 06:24 PM
Save excel file with pipe separated Vijay Kotian Excel Discussion (Misc queries) 5 November 3rd 06 06:21 PM


All times are GMT +1. The time now is 04:00 AM.

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"