+ Reply to Thread
Results 1 to 18 of 18

Macro that saves all open Workbooks

  1. #1
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Macro that saves all open Workbooks

    I am trying to save all Open workbooks using this code. It saves the first file just fine but gives a debug error on the Workbook.Saveas line the next time through the loop. I have six open workbooks that will need to be saved. Thanks for any help that can be offered.

    Please Login or Register  to view this content.
    Last edited by Traymond; 01-06-2011 at 11:44 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Macro that saves all open Workbooks

    Your code looks like it is trying to save each workbook as the same name. Activeworkbook.name would be the name of the workbook you are running the code from.
    Does each workbook already have a name?

  3. #3
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Macro that saves all open Workbooks

    yes they do. i just basically need it to save each open workbook with it's existing name into the N:\Junk folder
    Last edited by Traymond; 01-06-2011 at 10:19 AM.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro that saves all open Workbooks

    Please Login or Register  to view this content.



  5. #5
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Macro that saves all open Workbooks

    snb, i get an error on the workbooks.close false line . any suggestions ?

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro that saves all open Workbooks

    Are you renaming the files? If not
    Please Login or Register  to view this content.
    snb's code should be workbook.close false
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Macro that saves all open Workbooks

    still not working correctly

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro that saves all open Workbooks

    Try explaining what you want to do more fully, or at least answer what you have been asked

  9. #9
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Macro that saves all open Workbooks

    Example scenario: i have 6 workbooks that i always have opened. they are WB1,WB2,WB3,WB4,WB5,WB6. The macro will run from WB1. i need it to save each of these open workbooks into the N:\Junk folder and save them with the already existing name. In this example after i ran the macro i could open the N:\Junk folder and find WB1.xls WB2.xls WB3.xls WB4.xls WB5.xls WB6.xls workbook files. I hope this helps explain better what i am trying to do. Thanks

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Macro that saves all open Workbooks

    snb's code should work, try this minor amendment

    Please Login or Register  to view this content.

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro that saves all open Workbooks

    Please Login or Register  to view this content.
    Last edited by shg; 01-06-2011 at 11:31 AM.
    Entia non sunt multiplicanda sine necessitate

  12. #12
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macro that saves all open Workbooks

    I did not test this but would this work?
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro that saves all open Workbooks

    Save all the workbooks as the same name?

  14. #14
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: Macro that saves all open Workbooks

    I modified shg code just a little and it works perfectly !!!! thanks for the help. below is the code after i made changes. i did not need it to close any workbooks so i took that code out. I had to add the &"\" to the path . If i do not do this it always saves he files to the folder the file was opened from . don't get me to lying. Thanks again.

    Please Login or Register  to view this content.
    Last edited by Traymond; 01-06-2011 at 11:50 AM.

  15. #15
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Macro that saves all open Workbooks

    Quote Originally Posted by shg View Post
    Save all the workbooks as the same name?
    Same name but with a different number at the end, WB1, WB2, and etc.

  16. #16
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Macro that saves all open Workbooks

    Please Login or Register  to view this content.

  17. #17
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro that saves all open Workbooks

    Same name but with a different number at the end, WB1, WB2, and etc.
    Missed that, Mordred, sorry.

  18. #18
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro that saves all open Workbooks

    Please Login or Register  to view this content.
    What is wbname in that code, snb?

+ 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