xlCSV = comma, Save As CSV = semicolon delimited?

Felix Atagong

Active Member
Joined
Jun 27, 2003
Messages
359
I have daily Excel files to convert in 'European' CSV format, this is delimited with a semicolon.

If I open the file and do a 'manual' Save As CSV my file is allright.

When I write a macro and do a
ActiveWorkbook.SaveAs Filename:=Firma, FileFormat:=xlCSV, CreateBackup:=True
the delimiter is a comma. I tried with CSVWindows but the macro does NOT follow my 'default' windows separator which is semicolon (Excel 2000).

Anyone has a VBA solution or isn't there any?

PS: I can't change all commas in a semicolon afterwards because some of my 'fields' have commas in them, that's why I use semicolon as a separator!
 
I guess::
ActiveWorkbook.SaveAs Filename:= "driveletter:\folder\subfolder\sub-subfolder\" + Replace(ActiveWorkbook.Name, ".xls", ".csv"), FileFormat:= xlCSV, CreateBackup:=False
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello
I'm sorry to open this otherwise closed thread :/
I need to make a file such as the thread author.
But I need to save it as DOS.
I hope someone can help me out :)
 
Upvote 0
Upvote 0
I want to thank you kakzhetak
Your code help me a lot.
I just did a small change to jump lines that has errors


Code:
Function CreateCSV2(caminho As String)


    Dim rCell As Range
    Dim rRow As Range
    Dim sOutput As String
    Dim sFname As String, lFnum As Long
        
    'Open a text file to write
    sFname = caminho
    lFnum = FreeFile
   
    
    Open sFname For Output As lFnum
    Application.DisplayAlerts = True
    'Loop through the rows'
        For Each rRow In ActiveSheet.UsedRange.Rows
        'Loop through the cells in the rows'
        For Each rCell In rRow.Cells
            On Error GoTo ErrHandler: 'Error if has cell with error
            sOutput = sOutput & rCell.Value & ";"
        Next rCell
         'remove the last comma'
        sOutput = Left(sOutput, Len(sOutput) - 1)
        
        'write to the file and reinitialize the variables'
        Print #lFnum, sOutput


      
ErrHandler:
Resume NextLine
NextLine:
        sOutput = ""
     Next rRow
    
    'Close the file'
    Close lFnum
    
Exit Function


End Function
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top