Excel SaveAs method and naming conventions

14 Ansichten (letzte 30 Tage)
Emily
Emily am 21 Jun. 2022
Kommentiert: Emily am 29 Jun. 2022
I was curious if there was a built in WB.SaveAs method and how to use it.
I'm currently using WB.Save to highlight the difference between two excel files, but wanted to have not override the original document.
Also would like the files' names to end differently as well by using the folder's names at end, as excel doesn't want to open up two files with the same names.

Akzeptierte Antwort

Image Analyst
Image Analyst am 21 Jun. 2022
Bearbeitet: Image Analyst am 21 Jun. 2022
There is a SaveAs method. You can record a macro in Excel to see how it's typically used. Or see this:
You might also like to look at the functions strrep, fileparts, and sprintf to create new filenames.
I'm also attaching an Excel_utils class with a bunch of useful functions.
  6 Kommentare
Image Analyst
Image Analyst am 29 Jun. 2022
Try it this way:
baseFileName = sprintf('%s_%2.2d.xlsx', fname, file_index);
fullFileName = fullfile(pwd, baseFileName);
fprintf('Saving "%s".\n', fullFileName);
WB.SaveAs(fullFileName);
Emily
Emily am 29 Jun. 2022
Thank you everyone it works now!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by