excel vba activateworkbook.save changes date format

02773401 0 Reputation points
2025-03-13T07:42:16.75+00:00

I'm running a macro that creates a blank workbook using Workbook.Add and saves it in a specified location as a CSV (FileFormat:=xlCSV). It then copies data from another workbook into this sheet with formatting (Paste:=xlPasteValuesAndNumberFormats). Then I run "ActiveWorkbook.Close SaveChanges:=True".

When I open the CSV file, using Notepad to see the true format, the date formats are incorrect.

The strange thing is that, if I comment out "ActiveWorkbook.Close SaveChanges:=True" and manually close and save the file, using my mouse. the formatting is correct.

If I run "ActiveWorkbook.Save" and manually close the file, the format is also incorrect.

I can only deduce that it is vba ".save" that is changing the date formats.

I have checked my machine's regional settings and these are correct...

Does anyone know of a way to deal/fix this?

TIA!

Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,313 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.