Getting Rid of "Copy of"

Written by Allen Wyatt (last updated August 29, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


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, _
              FileFormat:=xlNormal
            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.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Specifying an Axis Scale in Microsoft Graph

Microsoft Graph is a handy way to add charts to your document if you don't have access to Excel. Here's how to adjust the ...

Discover More

Clearing the Contents of a Table

Want to get rid of information within a table, but not the table itself? Here's a guide to understanding the effects that ...

Discover More

Lost Data in Word

Use Word long enough and you eventually will lose some of your work. (And, it seems to be a rule that this will occur ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (menu)

Short-Lived Book1

If you have a problem that crops up when you first start Excel, it can be a bear to track down the cause of the problem. ...

Discover More

Stopping Excel from Converting UNC Paths to Mapped Drives

Did you know that if you create a link that uses a UNC path, Excel could rewrite that path to something entirely ...

Discover More

Stopping Date Parsing when Opening a CSV File

Excel tries to make sense out of any data that you import from a non-Excel file. Sometimes this can have unwanted ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four minus 0?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.