Forum

Excel, VBA : auto s...
 
Notifications
Clear all

Excel, VBA : auto save to CSV with semicolon

1 Posty
1 Users
0 Likes
1,960 Widok
0
Topic starter

Excel, VBA : auto save to CSV with semicolon

1 Answer
0
Topic starter

Use Local:=True – it’s depend on your system regional settings and separator field

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Sub SaveWorksheetsAsCsv()
 
Dim WS As Excel.Worksheet
Dim SaveToDirectory As String
 
Dim CurrentWorkbook As String
Dim CurrentFormat As Long
 
CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
SaveToDirectory = "C:test"
For Each WS In ThisWorkbook.Worksheets
    Sheets(WS.name).Copy
    ActiveWorkbook.SaveAs Filename:=SaveToDirectory & "questions.csv", FileFormat:=xlCSV, Local:=True
 
    ActiveWorkbook.Close savechanges:=False
    ThisWorkbook.Activate
Next
 
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
Application.DisplayAlerts = True
 
End Sub
Sub SaveWorksheetsAsCsv()

Dim WS As Excel.Worksheet
Dim SaveToDirectory As String

Dim CurrentWorkbook As String
Dim CurrentFormat As Long

CurrentWorkbook = ThisWorkbook.FullName
CurrentFormat = ThisWorkbook.FileFormat
SaveToDirectory = "C:test"
For Each WS In ThisWorkbook.Worksheets
    Sheets(WS.name).Copy
    ActiveWorkbook.SaveAs Filename:=SaveToDirectory & "questions.csv", FileFormat:=xlCSV, Local:=True

    ActiveWorkbook.Close savechanges:=False
    ThisWorkbook.Activate
Next

Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=CurrentWorkbook, FileFormat:=CurrentFormat
Application.DisplayAlerts = True

End Sub

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: