+ Reply to Thread
Results 1 to 2 of 2

Save a file and a Copy

  1. #1
    Registered User
    Join Date
    05-11-2011
    Location
    St Pete, FL
    MS-Off Ver
    Excel 2003
    Posts
    3

    Save a file and a Copy

    I am working on a project that saves Excel files with a variable name (File_Name) to designated folder. I need to also need to save a backup file to a separate designated folder with out overwriting the original file. I have tried SaveCopyAs but it keeps overwriting the original file. Help!! The code I am using to save the file is listed below.

    Sub SaveAs()
    '
    ' SaveAs Macro using a name from a cell and a set file path
    '
    If Range("File_Name") = "" Then
    MsgBox "Please Enter The Required Information"
    Exit Sub
    End If
    fname = Range("File_Name").Value
    fileSaveName = Application.GetSaveAsFilename(InitialFileName:=FilePath" & fname, _
    FileFilter:="Excel Workbook (*.xls), *.xls")

    If fileSaveName <> False Then
    On Error GoTo errhandler
    ActiveWorkbook.SaveAs fileSaveName
    MsgBox "The Manual Dispatch has been saved."
    End If
    Exit Sub

    errhandler: MsgBox "THE FILE HAS NOT BEEN SAVED !", , "WARNING"

    End Sub

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Save a file and a Copy

    Please edit your post enclosing your code in tags per the forum rules.

    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Select your code and click the [#] button at the top of the post window (if you are editing an existing post, press Go Advanced to see the [#] button).
    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1