+ Reply to Thread
Results 1 to 9 of 9

At A Loss: Click Save - Saves To Multiple Locations

  1. #1
    Registered User
    Join Date
    01-15-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    At A Loss: Click Save - Saves To Multiple Locations

    Hey guys,

    This is my first time posting on the forum but I've been following the posts for quite some time. Im a novice Macro user and took the first step by looking through all of the old posts. Here is what Im trying to do but Im really struggling.

    1. When a user clicks the save button or presses the save disk the excel file is saved to two locations. I don't want to use a macro command button as the individuals using the tool will definitely forget.
    C:\Users\g068716\Desktop\Drop\Dropbox\Ancaster\
    C:\Users\g068716\Desktop\Personal\

    2. When it saves it doesn't ask if its ok to overwrite the file. Just overwrite and save.

    I've looked through piles of examples and the ones that look promising just dont seem to work. Here is what I have right now.

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    'All saves should be placed between display alert toggle
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:="C:\Users\g068716\Desktop\Drop\Dropbox\Ancaster\Book3.xlsm"
    ActiveWorkbook.SaveAs Filename:="C:\Users\g068716\Desktop\Personal\Book3.xlsm"
    Application.DisplayAlerts = True
    Cancel = True
    End Sub

    When I select Save from the menu (File -> Save) nothing happens. I'm really at a loss. I know Im not the first person to ask for help with this problem but the other solutions seem to require command buttons or I couldnt figure out.

    Thanks in advance. I've really been stuck on this for a while.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: At A Loss: Click Save - Saves To Multiple Locations

    Hi and welcome to the forum,
    Please use code tags around your code as per forum rules.

    You can try this code :
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Registered User
    Join Date
    01-15-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: At A Loss: Click Save - Saves To Multiple Locations

    Hey Thanks for the quick reply.

    The code is very similar to my own except for the first line but I didnt seem to work. I copied the code, pasted in the module of the workbook, saved the file, and tried to File - Save. Nothing happened. No file was created in either location.

    Any idea what might be wrong.

    Thanks,

  4. #4
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: At A Loss: Click Save - Saves To Multiple Locations

    Did you place the code in a standard Module???

    Since this is a workbook event macro, you must place the code in THISWORKBOOK module. It will not work if it is placed in a standard module.

    Note that the lines I changes are .SAVEAS to .SAVECOPYAS

    Tested on my PC and worked flawlessly.

  5. #5
    Registered User
    Join Date
    01-15-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: At A Loss: Click Save - Saves To Multiple Locations

    THISWORKBOOK module. I must be newer than I thought at this but where would this be located. I've opened the edited. Double clicked on book3.xlsm from Project window. In it are three sheets and a module 1. I placed it in module 1 within book3.xlsm. Is that right?

  6. #6
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: At A Loss: Click Save - Saves To Multiple Locations

    after double clicking book3.xlsm in project window
    there should be Microsoft Excel Objects folder (not module) which you can click on
    then it will show up sheet1, sheet2, etc...with last one being thisworkbook
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  7. #7
    Registered User
    Join Date
    01-15-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: At A Loss: Click Save - Saves To Multiple Locations

    Yes I got that to work in thisworkbook but when I save (it works) but when I try and close the file. Simply click the small 'x' in the corner it brings up a message window "Do you want to save the changes you made to 'Book3.xlsm'" I can click "Save" an infinite number of times and Im forced to selecting Don't Save. Is there any way to fix that?

    Thanks again. I do really appreciate the help

  8. #8
    Registered User
    Join Date
    01-15-2014
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: At A Loss: Click Save - Saves To Multiple Locations

    I guess I should provide a bit more clarity. So although its saving in two locations (which works now) the file Im clicking Save on is in a third location. Its simply on the desktop. Im guessing the code isnt saving this file which is why it keeps asking me to save. Endless loop. Anyways I tried to extend the code to include the file on the desktop but it asks to debug.

    ActiveWorkbook.SaveCopyAs Filename:="C:\Users\g068716\Desktop\Book3.xlsm"

  9. #9
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: At A Loss: Click Save - Saves To Multiple Locations

    Hi,
    I tested and got the same problem as you when exiting the file.
    So I changed the macro to this and it seems to work :

    Please Login or Register  to view this content.
    Again, the macro must be placed in THISWORKBOOK module.
    It will create a copy to the 2 other locations everytime this workbook is saved.
    When you exit the file, you will still get the option to save or not the changes. If you click YES then a copy will be made.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 05-22-2013, 05:35 PM
  2. Replies: 1
    Last Post: 07-12-2012, 11:00 PM
  3. Open Multiple Files to Update - Close & Save with One click
    By awaken88 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-13-2012, 05:24 PM
  4. Save to multiple locations
    By flourboy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-04-2007, 04:08 PM
  5. request macro to save file to multiple, separate locations
    By Joseph Spain in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2005, 10:46 AM

Tags for this Thread

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