Excel.Tips.Net ExcelTips (Menu Interface)

Getting Rid of "Copy of"

Anna Lea has a read-only workbook that she uses as a template for a daily report that she creates. The file name is quite long, and ends in 20507xx. When she double-clicks on the workbook, it opens and shows that it is read-only. She makes her changes, and then uses Save As. Since Excel recognizes that the file is read-only, it suggests a new file name that consists of the old one with the words "Copy of" as a prefix. Anna wants to get rid of the "Copy of" so that all she has to do is change the "xx" portion of the file name to create the day's report.

The "Copy of" verbiage is added by Excel automatically. If you are using Save As, there is no way to change this without using a macro to control the saving process. The following macro, saved as part of the ThisWorkbook object, shows how this can be done.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI _
  As Boolean, Cancel As Boolean)
    Dim sTemp As String
    Dim sCheck As String
    sCheck = "xx.xls"

    If SaveAsUI Then
        sTemp = ThisWorkbook.Name
        If Right(sTemp, Len(sCheck)) = sCheck Then
            sTemp = Left(sTemp, Len(sTemp) - Len(sCheck))
            sTemp = sTemp & Format(Now, "dd") & ".xls"
            sTemp = ThisWorkbook.Path & "/" & sTemp
            ThisWorkbook.SaveAs Filename:=sTemp, _
            Cancel = True
        End If
    End If
End Sub

The macro first checks to see if the Save As dialog box is about to be displayed. If it is, then the workbook's name is assigned to the sTemp variable. This name is checked to see if the last six characters are "xx.xls" (from the sCheck variable). If they are, then the workbook is assumed to be the one where the name needs to be changed.

First the "xx.xls" characters (or whatever you've assigned to sCheck) are stripped from the end of the workbook name. Then today's date (two digits, for the day of the month) is appended to the file name, followed by the ".xls" suffix. Finally, the workbook is saved using this newly constructed filename. The Cancel flag is set to True so that the Save As dialog box never displays.

Note that the name is never checked for the verbiage "Copy of". The reason for this is simple: The wording is not added to the start of the file name until the actual Save As dialog box is displayed. Before that point (when this event handler is being executed) the workbook name remains unchanged.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3064) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Related Tips:

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

Byron Whitman    31 May 2016, 23:49
How do I delete all these copies? The make another copy every time!
Michael (Micky) Avidan    13 Feb 2016, 06:17
Sorry for my bad English but I'm sure you will understand the following:

The process is, slightly, complex, and requires some skill in using the VBA Editor (VBE).

*** ALL that follows goes into the PERSONAL file.

1. Add a new ClassModule and call it: MyEventsClass

2. Type into it the code below:
Public WithEvents XL_Event As Application
Private Sub XL_Event_WorkbookBeforeSave (ByVal Wb As Workbook, ByVal SaveAsUI As Boolean, Cancel As Boolean)
If instr (Wb .Name, "Copy of") Then
Application.EnableEvents = 0
Cancel = True
Wb.SaveAs Trim (Application.Substitute (Wb.FullName, "Copy of", ""))
Application.EnableEvents = 1
End If
End Sub

3. In a regular Module (existing or new) type the command:
Public XL_Events As New MyEventsClass

4. Into ThisWorkbook module add the Workbook_Open event macro and type into it the command:
Set XL_Events.XL_Event = Application

5. Save the PERSONAL file > close and restart "Excel".

6. Try to save an open workbook which has the "Copy of" Prefix in its name.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)

Joanne Mueller    12 Feb 2016, 09:46
Let me add my annoyance to this stupid prefix that is added to every Excel worksheet I receive and want to save. I am not a programmer and have no idea what or how to find "ThisWorkbook" and add the macro as suggested above. Microsoft just needs to eliminate this stupid harassment.
Richard Reynolds    28 Aug 2015, 10:04
Once can only ask ... Why? WHY?? I exchange Excel files with lots of people via E-mail. Every one is aggravated by this "Copy of..." behavior of Excel.

Why not "Copy of ..." a Word or PowerPoint document? (Oops, did I give Microsoft an idea! Hope NOT!)
Jon Faulkner    01 Dec 2014, 17:27
This is a lot of trouble. Is there a universal switch tog et rid of this annoying behavior? I get this every time I save a document from e-mail. I think this is another reason to move our firm (only 800 users of Excel) away from Microsoft to Google Docs!

Microsoft must absolutely HATE its customers to stop innovating and instead be annoying!
Brian Fletcher    09 Dec 2013, 16:39
Hello Allen,
Thanks for the useful code. I wonder if there is a way to disable this in all workbooks? I would be quite content to eliminate this behavior from Excel in its entirety.
Thanks again!

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.