+ Reply to Thread
Results 1 to 9 of 9

Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

  1. #1
    Forum Contributor
    Join Date
    12-20-2011
    Location
    United States, Ohio
    MS-Off Ver
    Excel 2010
    Posts
    295

    Question Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    I have a routine that opens excel, does stuff, and then I want to do is close ALL instances of excel down (all workbooks) and SAVE all changes - but I dont want the system to ask me if I want to SAVE.

    How do I close and save without the prompt?

    The VBA code will reside in ACCESS. So want to close all instances of excel - meaning there is no need to leave the "activework" open.

    Since this questions is dealing with excel, I thought I would post my question here.

    An example (not exactly) of what I have is below.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    start macro with
    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    Hi, clemsoncooz,

    this code is unreliable as may be. You want to close all workbooks down you would need to make clear which path and name should be used for all workbooks which arenīt saved in the Excel application. The Code patel45 delivered wonīt be of any use if there is an unsaved workbook which always display the SaveAs display and should be used as xlApp.DisplayAlerts and not Application.DisplayAlerts.

    I would use the CreateObject, open the relevant workbook, do my action, save and close the workbook, quit the application and release all objects. And since there was more than one workbook open I had to specify which workbook to use as well as the worksheet on which to perform the action.

    I think both posters missed the line
    The VBA code will reside in ACCESS.
    Ciao,
    Holger
    Last edited by HaHoBe; 11-19-2013 at 08:14 AM.
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    Hi, Norie,

    just for me to get it sorted: Application - Workbook - Worksheet - Range?

    Please Login or Register  to view this content.
    isnīt clear for me at first sight as neither a workbook nor a worksheet is given for the Application (resulting in RTE 1004 for a newly created instance).

    Ciao,
    Holger

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    Holger

    I kind of ignored those lines, perhaps wrongly, as the question was about closing workbooks.

    This isn't quite right but will work - Range("A1") will refer to A1 on the active sheet
    Please Login or Register  to view this content.

  8. #8
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    Hi, Norie,

    thanks for coming back on that. I know it sounds a bit out of the box in an Excel Forum but please close down Excel and start the procedure from Access. No workbook is open, the RTE will occur no matter if the lines may work with an open book or not. And I think my comment about not being to stable is not so far out of the world as no workbook is specified (what about a personal macrobook), no worksheet.

    I know Iīm pretty oldfashioned but I like to know what I am working on which I canīt guarantee with this kind of code.

    Ciao,
    Holger

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Close ALL Workbooks and Save Changes WITHOUT asking do I want to save.

    Holger

    I'm kind of assumed it's not 'real' code.

    It would work if this code was removed, even if no instance of Excel was open.
    Please Login or Register  to view this content.
    PS When testing the 'code' I was using Access.

+ 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: 1
    Last Post: 10-25-2013, 06:10 PM
  2. Need macro to open, refresh, save, close 50 workbooks in a folder.
    By paulcg in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-11-2012, 09:23 AM
  3. custom save and close sub causing other workbooks to crash
    By Jaron_t in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-11-2012, 05:56 PM
  4. Macro to close all open workbooks save two not working
    By drajanm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2011, 05:58 AM
  5. Code, that disables save, save as and close commands
    By mgmetev in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2009, 06:31 PM

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