Hello everyone,
Hope life's great wherever you are reading this from.
I am building a very simple macro to be able to export a selection in a sheet to a .csv file utf-8 encoded with ; and "" and field and text delimiters.
I have the below code so far which is a mash-up of several threads I read on the topic, the idea is that I need to be able to generate those .csv with the name of the sheet as name of the file.
I get an error message "Run-time error '1004' Cannot access '3. Output-OF0106_01_2016 01 45 PM.csv'."
I pasted the code below, I would really appreciate if you can help.
Thanks a million in advance.
Cheers.
luck_excel
Code
Sub csv()
'
' csv Macro
'
MName = ActiveSheet.Name
MDir = ActiveWorkbook.Path
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
ActiveWorkbook.SaveAs MDir & "/" & MName & Format(Now(), "mm_dd_yyyy hh mm AMPM") & ".csv", _
FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWorkbook.Close
End Sub
Display More