I am trying to copy an Excel workbook from Folder X to Folder Y, and in the event that a file of that name already exists in Folder Y, the file is not overwritten but rather the new file is given a suffix of '- Copy', '- Copy (2)' etc - essentially recreating the manual process for copying and pasting the same file in a folder.
I would have thought that there would be a function that allows you to do this but nothing I have tried so far seems to fit the exact requirements:
Workbook.SaveAs
prompts the user with a message asking whether the file should be replacedWorkbook.SaveCopyAs
simply overwrites the file without a promptThe
FileSystemObject.CopyFile
method has an 'overwrite' parameter, however this simply errors if set to false and the file already exists, which is expected behaviour according to the Microsoft website
It wouldn't be difficult to create a counter which increments based on the number of existing files in the selected folder (.xls (1), .xls (2) etc), but I hoped that there might be a more direct approach than this.