This post repeats the processes and discussions of last post for saving as CSV Macintosh and CSV MS-DOS. ( We will assume we only have one worksheet showing at the start , so will not have the initial pop up warning ( https://imgur.com/QLscU1a )
Macintosh
We record a macro whilst doing Save, SaveAs , Close.
We find that we get the following warnings, answering always Yes
Save or SaveAs
WarnugOnSaveOrSaveAsMacintoshCSV.JPG : https://imgur.com/jCJ5XjK
Close
WarningOnCloseForSavingChangesDespiteAlreadySavedM acintoshCSV.jpg : https://imgur.com/sShcoNq
SecondWarningOnClose SameAsWarningOnSaveOrSaveAsMacintoshCSV.JPG : https://imgur.com/Q20iknI
Here is the macro obtained from the recorder.
Code:
Sub SaveSaveAsCloseMacintoshCSV() ' https://excelfox.com/forum/showthread.php/2559-Notes-tests-text-files-manipulation-of-text-files-in-Excel-and-with-Excel-VBA?p=13741&viewfull=1#post13741
' Save manually
ActiveWorkbook.Save
' SaveAs manually
ActiveWorkbook.SaveAs Filename:="F:\Excel0202015Jan2016\ExcelFox\vixer\csv Text file Chaos\CSV (Macintosh)A1B1A2.csv", FileFormat:=xlCSVMac, CreateBackup:=False
' Warnings same for both: https://imgur.com/jCJ5XjK
' Close manually
ActiveWorkbook.Save: ActiveWorkbook.Close
' two warnings obtained : https://imgur.com/sShcoNq , https://imgur.com/Q20iknI
End Sub
This is what it the produced text file, like in a text editor
answering always Yes
cellA1;cellB1cellA2;
Note: if I copy and paste that into Word, then I get
cellA1;cellB1
callA2;
Analysing what is there I see the typical results expected for a Macintosh csv file
"cellA1" & ";" & "cellB1" & vbCr & "callA2" & ";" & vbCr & vbLf
If I say No on the Close, then I get only that warning: The file closes without the second warning. But the results are the same
If I run the recorded macro, ( on a newly made file ) , then there is no warning pop up on Save or SaveAs. I just get the single warning asking me if I want to save the changes on Close ( despite already with the preceding coding having Saved and SaveAsd and Saved before the Close
MacroRunWarningOnCloseForSavingChangesDespiteAlrea dySavedMacintoshCSV.JPG : https://imgur.com/KYp1AYw
The resulting text file has commas , for the separator
CellA1,CellB1CellA2,
I get the same results if I answer Yes or No to the warning
CSV (MS-DOS)
We record a macro on Save, SaveAs , Close. We get the following warnings, answering always Yes
Save or SaveAs
Manual SaveAs or Save CSV (MS-DOS) warning.JPG : https://imgur.com/vkikEUS
Close
Manual Close CSV (MS-DOS) first warning.JPG : https://imgur.com/uvh64E6
Manual Close CSV (MS-DOS) second warning.JPG : https://imgur.com/sCPSmFX
This macro is obtained
Code:
Sub ManualSaveSaveAsCloseCSV_MS_DOS_()
' Manual Save
ActiveWorkbook.Save
' Manual SaveAs
ActiveWorkbook.SaveAs Filename:="F:\Excel0202015Jan2016\ExcelFox\vixer\csv Text file Chaos\CSV (MS-DOS)A1B1A2.csv", FileFormat:=xlCSVMSDOS, CreateBackup:=False
' warning same for both https://imgur.com/vkikEUS
' Close manually
ActiveWorkbook.Save: ActiveWindow.Close
' two warnings obtained https://imgur.com/uvh64E6 , https://imgur.com/sCPSmFX
End Sub
If I say No on the Close, then I get only that warning: The file closes without the second warning. But the results are the same.
The resulting text file looks like this
cellA1;cellB1
callA2;
If I run the macro produced from the macro recording, then I only get the first warning on at the Close
MacroRunWarningOnCloseForSavingChangesDespiteAlrea dySavedCSVMSDOS.JPG : https://imgur.com/aCzwGqa
It makes no difference if I answer Yes or No
The results are that I get a file with comma , as the delimiter
cellA1,cellB1
callA2,
Final Conclusions on Save SaveAs Close for the 3 CSV file types
The following conclusions are in general identical for the three CSV types
In my Excel, if I try to save or close manually a file as CSV type, then the separator becomes a ;
Any attempt to do the same with a macro always results in a , as the separator, ( even if the macro had been derived from a macro recording when doing it manually which resulted in the ; as separator ).
It makes no difference to the results by selecting a YES or No on any of the two possible prompts on a Close.
( The single prompt on a Save or SaveAs gives me the chance to go back to the save dialogue to choose an extension other than .csv)
Bookmarks