Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing inactive workbook windows (Excel '97)

    I have two files opened, a template and a normal workbook file. While in the template I run a macro that copies one of the workbook's sheets into the template. I want to be able to close the worksheeet file without saving the changes. I run the following: ActiveWindow.ActivateNext
    ActiveWindow.Close but get the Excel message "Do you want to save the changes you made to (file name). How can I run this without this message.

    Thanks. <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  2. #2
    New Lounger
    Join Date
    Nov 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing inactive workbook windows (Excel '97)

    Add these to the beginning of your macro:

    Application.DisplayAlerts = False 'Stops Excel from asking questions like do you want to save, etc
    Application.EnableEvents = False 'Stops Autoexec Macros from running when you open the second file
    Application.ScreenUpdating = False 'Stops Excel from updating the screen while it is running the macro


    Just remember to change them back to True at the end of the macro <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  3. #3
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Closing inactive workbook windows (Excel '97)

    If you know the name of the workbook use

    With Workbooks("WorkbookName")
    .Saved = True
    .Close
    End With

    If you are certain there are only 2 workbooks with a single window each you could use :

    ActiveWindow.ActivateNext
    With ActiveWorkbook
    .Saved = True
    .Close
    End With

    Andrew C

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing inactive workbook windows (Excel '97)

    Or

    Workbooks("YourBook").Close False
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    New Lounger
    Join Date
    Nov 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing inactive workbook windows (Excel '97)

    Sorry, this posted to the wrong list

  6. #6
    3 Star Lounger
    Join Date
    Apr 2002
    Location
    Atlanta, GA
    Posts
    220
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Closing inactive workbook windows (Excel '97)

    Thank you all for your helpful advice.

    <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>

Posting Permissions

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