I am a beginner in macro. In my excel file, I want to put a button which can take a back up in the same Excel file but in another format.
The file will be saved in .csv format.
Printable View
I am a beginner in macro. In my excel file, I want to put a button which can take a back up in the same Excel file but in another format.
The file will be saved in .csv format.
The below is an example in which I have the filename (without .xls).
The active file is saved in .csv file without closing it.
Code:Sub backup_file_csv ()
rep_backup = "E:\file_csv"
filename = activeworbook.name
if instr (filename,".xls")> 0 then
filename_csv = mid (filename, instr (filename,".xls") -1, len (filename) - 3) & "csv"
Application. DisplayAlerts = False
ActiveWorkbook. SaveAs Filename: = rep_backup & filename_csv, _
FileFormat: = xlCSV, CreateBackup: = False
Application. DisplayAlerts = True
else
msgbox "The file is not an active file with extension .xls, no treatment done"
End if
End Sub
Thank you for your help. I don't know if it was not possible to go through simple manipulation of an object? Or is it mandatory to go through the code?
I do not understand the meaning of what you are trying to say.
Otherwise, there is the possibility: in the File menu -> Save As - CSV file type
This is because at each record, there is a warning message which prevents the loss of information due to the change in format.