in xla  Add-In need a SaveAs  and  rename.

Posted on 2011-10-28
Last Modified: 2012-05-12
excel 2003 add-in...

I have an add-in I wrote but trying to save the current workbook I'm working on but the code keeps  re-saving the add-in.

I need the workbook I'm working on to keep the same.
But make a backup copy of the file and place in a directory.

So if the file I'm working on is called  "Kellogg.xls" I need to stay in this copy  but make a backup copy of the in the folder specified in the code.

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
End Sub

Public Sub subExportBackup()
    Dim strTemp As String
    Dim f As String
    Dim strFileName As String
    strFileName = "C:\Program Files\Ent\AutoBackups\" & ActiveWorkbook.Name & "_" & Format(Date, "YYYYMMDD") & " " & Format(Time, "") & ".txt"
    f = strFileName  '  this is the file name
        ActiveWorkbook.SaveAs f

End Sub

Open in new window

Question by:fordraiders
    LVL 29

    Accepted Solution

    Try ActiveWorkbook.SaveCopyAs

    LVL 3

    Author Closing Comment



    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
    Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
    The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
    This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now