in xla  Add-In need a SaveAs  and  rename.

Posted on 2011-10-28
Medium Priority
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, "hh.mm.ss") & ".txt"
    f = strFileName  '  this is the file name
        ActiveWorkbook.SaveAs f

End Sub

Open in new window

Question by:Fordraiders
LVL 29

Accepted Solution

leonstryker earned 2000 total points
ID: 37045227
Try ActiveWorkbook.SaveCopyAs


Author Closing Comment

ID: 37045403


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

850 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