Results 1 to 5 of 5

Thread: VBA Macro To Save And Copy File To Different Locations

  1. #1
    Junior Member Zaigham's Avatar
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0

    Question VBA Macro To Save And Copy File To Different Locations

    Hi
    Please provide me a macro to save an excel file at its original location as well as at a specific folder. I want to keep this macro at QAT so whenever I press its button, the opened file may be saved at its original location as well as at a specific location e.g., a folder named "Updated" with the same filename.
    Thanks
    Zaigham

  2. #2
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    You probably already know how to assign a macro button in the QAT. Let me know in case you don't. Use this following code for what you've asked.

    Code:
    Sub SaveAndCopyToAnotherLocation()
    
        ActiveWorkbook.Save
        FileCopy ActiveWorkbook.FullName, "D:\Updated\" & ActiveWorkbook.Name
        
    End Sub
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  3. #3
    Junior Member Zaigham's Avatar
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0
    Thanks for help. It gives me (Run-time error "70": Permission denied).
    Code:
    ActiveWorkbook.Save
        FileCopy ActiveWorkbook.FullName, "F:\WorkUpdates\" & ActiveWorkbook.Name

  4. #4
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,402
    Rep Power
    10
    Try replacing the second line with this

    Code:
    ActiveWorkbook.SaveCopyAs "F:\Update\" & ActiveWorkbook.Name
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  5. #5
    Junior Member Zaigham's Avatar
    Join Date
    Mar 2013
    Posts
    13
    Rep Power
    0
    It works fine. Thank you very much.

Similar Threads

  1. Replies: 4
    Last Post: 06-20-2013, 04:25 PM
  2. Save Excel 2010 File In CSV Format VBA
    By mag in forum Excel Help
    Replies: 7
    Last Post: 01-08-2013, 07:16 PM
  3. Macro for Opening files and copy the contents of the File
    By ravichandavar in forum Excel Help
    Replies: 16
    Last Post: 08-15-2012, 09:17 PM
  4. Copy Sheets To New Workbook And Save
    By Prabhu in forum Excel Help
    Replies: 5
    Last Post: 09-06-2011, 09:35 PM
  5. Save File In CSV Format VBA
    By Raj Kumar in forum Excel Help
    Replies: 3
    Last Post: 06-01-2011, 07:22 AM

Posting Permissions

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