Notifications
Clear all
BugOverflow
1
Posty
1
Users
0
Reactions
2,359
Widok
0
25/09/2015 4:24 pm
Topic starter
Excel, VBA : auto save to CSV with semicolon
1 Answer
0
25/09/2015 4:26 pm
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