Found the below code online, though it's a bit strange when I run the macro for dates as my dates will convert from: [DD/MM/YYYY] to [MM/DD/YYYY]
example: 31/07/2017 to 07/31/2017.
anyone able to assist, I would want to keep it was [DD/MM/YYYY].
Refer to below:
Dim strName As String
Dim filepath As String
Application.ScreenUpdating = False
strName = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name & " " & ActiveSheet.Name & ".csv"
ActiveSheet.Copy 'copy the sheet as a new workbook
ActiveWorkbook.SaveAs Filename:=strName, FileFormat:=xlCSV
ActiveWorkbook.Close SaveChanges:=False
Application.ScreenUpdating = True
MsgBox "File has been Created and Saved as: " & vbCr & strName, , "Copy & Save Report"
thanks,
Depending on your local language settings (specified in Control Panel), the following should work:
ActiveWorkbook.SaveAs Filename:=strName, FileFormat:=xlCSV, Local:=True
This should ideally be used by specifying the TextCodepage
parameter of the SaveAs
method. However, according to MSDN reference , this parameter is ignored for all languages of Excel.
A previous question on SO addresses this, and suggests instead using FileFormat:=xlUnicodeText
, and then setting the extension to .csv
, ie:
ActiveWorkbook.SaveAs Filename:=strName & ".csv", FileFormat:=xlUnicodeText
However, this does not seem to work for my part when testing your scenario.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.