+ Reply to Thread
Results 1 to 5 of 5

Saving and Closing multiple files and Excel program

  1. #1
    Roger
    Guest

    Saving and Closing multiple files and Excel program

    I am looking for 2 macros that I had in Excel 5 which don't work in Excel
    2002. The first is a macro that Saves and Closes all open files except any
    file which is BOOK1, or BOOK2 etc. The second is a macro that Closes all
    open files and doesn't save them except any file which is BOOK1, or BOOK2
    etc. In both cases the workbook is left open and the BOOK files are not
    saved.

    Any help would be greatly appreciated,

    Roger



  2. #2
    Registered User
    Join Date
    08-20-2003
    Location
    Luton, England
    Posts
    63
    Like tihs ?
    Please Login or Register  to view this content.
    Regards
    BrianB
    Most problems are caused by starting from the wrong place.
    Use a cup of coffee to speed up all Windows processes.
    It's easy until you know how.
    -----------------------------------------

  3. #3
    Roger B.
    Guest

    Re: Saving and Closing multiple files and Excel program

    Hi Brian, many thanks for your code. I wrestled with it for a couple of
    hours to get it to work but no luck. Here is the macro that I was working
    on. Your macro seemed to work for the Book1 etc files but not for the other
    files. I want to keep only these files open if they are already open. Can
    you see where I went wrong?

    Many thanks,

    Roger

    Sub KeepingSpecialFilesOpen()
    Dim book As Variant
    For Each book In Workbooks
    If book.Name <> "Book1" Or book.Name <> "Book2" Or book.Name <> "Book3"
    Or book.Name <> "Book4" Or
    book.Name <> "Book5" Or book.Name <> "Work04.xls" Or book.Name <>
    "WORK05.XLS" Then book.Close saveChanges:=True
    Next book
    End Sub


    "BrianB" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Like tihs ?
    >
    > Code:
    > --------------------
    >
    > Sub SaveBooksUntested()
    > Dim MySave As Boolean
    > rsp = MsgBox("Save Non 'Book' files ?", vbYesNoCancel)
    > If rsp = vbCancel Then Exit Sub
    > If rsp = vbYes Then MySave = True
    > If rsp = vbYes Then MySave = False
    > '-----------------------------------------------------------
    > For Each wb In Workbooks
    > If wb.Name <> "Book1.xls" And wb.Name <> "Book2.xls" Then
    > wb.Close savechanges:=MySave
    > End If
    > Next
    > End Sub
    >
    > --------------------
    >
    >
    > --
    > BrianB
    >
    >
    > ------------------------------------------------------------------------
    > BrianB's Profile:
    > http://www.excelforum.com/member.php...info&userid=55
    > View this thread: http://www.excelforum.com/showthread...hreadid=386951
    >




  4. #4
    Registered User
    Join Date
    08-20-2003
    Location
    Luton, England
    Posts
    63
    If you compare the 2 sets of code carefully your common error is obvious.

  5. #5
    Roger B.
    Guest

    Re: Saving and Closing multiple files and Excel program

    Brian, I see several items that are different. I tried most variations but
    didn't get anywhere. Why does it want to save the Book1 etc files?
    Tks,
    Roger



    "BrianB" <[email protected]> wrote in
    message news:[email protected]...
    >
    > If you compare the 2 sets of code carefully your common error is
    > obvious.
    >
    >
    > --
    > BrianB
    >
    >
    > ------------------------------------------------------------------------
    > BrianB's Profile:
    > http://www.excelforum.com/member.php...info&userid=55
    > View this thread: http://www.excelforum.com/showthread...hreadid=386951
    >




+ 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