Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88054

Save Copy as CSV MSDOS (Without closing/changing workbooks)

$
0
0

I have a macro that saves the current workbook as CSV MSDOS format.

Here's my code:

Sub Save_CSV()
Dim Location, FileName As String
            Location = "C:\Users\myawesomename\OneDrive\Desktop\GM MRP\"
            FileName = Left(ActiveWorkbook.name, Len(ActiveWorkbook.name) - 5)
                ActiveWorkbook.SaveAs FileName:= _
                    Location & FileName & ".csv", FileFormat:= _
                    xlCSVMSDOS, CreateBackup:=False
                ActiveWorkbook.Save
End Sub

After I use this macro, I'm no longer working on the xlsv. Rather, I'm working on the CSV version with all the sheets still present. If I close the workbook without saving it, I can then open the CSV file and only the first sheet is present. It's fine that only the first sheet is present but I want it to save a separate CSV file (with the first sheet only present) while continuing to work on the XLSX file without opening the CSV at all. I'm not trying to save each sheet as a separate file.

I tried several things including changing "Activeworkbook.SaveAs" to "Activeworkbook.savecopyas" but I couldn't achieve the desired result.

Thank you,


Viewing all articles
Browse latest Browse all 88054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>