VBA regional settings vs saving as CSV

maxon

New Member
Joined
Oct 28, 2015
Messages
43
Hi All,I need your help with following case. I build a macro, which have to save the data as csv file, which can be used by other application.Everything is working except saving part. During saving as CSV I see in results file that every line of data is in quotes "...".The problem occurs in Italian language setting, when I set English everything is fine... its totally weird.

Code:
Sub Save_file()
Dim wb, NewWb As Workbook
Dim ws As Worksheet
Dim nCol, nRow As Integer
Dim s As String
Dim LastRow As Integer
Set wb = ThisWorkbook
Set ws = wb.Sheets("RESULT")
wb.Saved = True
ws.Range("A1").CurrentRegion.Copy
ws.Range("A1").PasteSpecial xlPasteValues
LastRow = ws.Range("A" & Rows.Count).End(xlUp).row
Set NewWb = Workbooks.Add
'convert columns to text
For nRow = 1 To LastRow
    nCol = 1
    Do Until ws.Cells(nRow, nCol).Value = ""
        If (s = "") Then
            s = ws.Cells(nRow, nCol).Value
        Else
            s = s & ";" & ws.Cells(nRow, nCol).Value
        End If
        nCol = nCol + 1
    Loop
NewWb.Sheets(1).Cells(nRow, 1).Value = s
s = ""
Next nRow
 
Application.DisplayAlerts = False
NewWb.SaveAs Filename:=ThisWorkbook.Path & "\IMPORT\" & "FILE.csv", FileFormat:=xlCSV, Local:=True
NewWb.Close
wb.Close = False
Application.DisplayAlerts = True
End Sub


The code is creating from several columns text file delimited with ; and then save as CSV, how its possible that its related to language setting and how to fix it? Thanks
 
Last edited:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,215,831
Messages
6,127,142
Members
449,363
Latest member
Yap999

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