+ Reply to Thread
Results 1 to 11 of 11

Thread: conflict between auto save&close macro and show/hide sheets macro

  1. #1
    Registered User
    Join Date
    09-25-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    51

    conflict between auto save&close macro and show/hide sheets macro

    Hello

    I am trying to make a save&close workbook macro.

    I found several examples on google, but unfortunatly it conflicts with another macro I use for forceing users to enable macros (hide all sheets except one if macros are disabled).

    The attached file is an example contaning the save&close code and the show/hide sheets depending on macros enabled.

    If the file is opened with macros disabled then only one sheet will be visible.
    If the file is opened with macros enabled other sheets are visible.

    The problem if that this code uses a custom save, witch makes the save&close not save... (in module1 and in ThisWorkbook)

    The pourpose of the save&close is to make sure some users don't forget the excel open and thus block access to it. So if a certain idele time passes excel has to save and close without any confirmation messages.

    Can anyone help me adjust the code in the attached file so that it saves before auto closing?

    Thank you

    p.s: I raised the same problem with no success so far here:
    http://www.thecodecage.com/forumz/me...ets-macro.html
    here:
    conflict between auto save&close macro and show/hide sheets macro - dBforums
    and here:
    conflict between auto save&close macro and show/hide sheets macro - MrExcel Message Board
    Attached Files Attached Files
    Last edited by alexandruc; 10-20-2009 at 01:23 AM.

  2. #2
    Valued Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Eastlake Ohio
    MS-Off Ver
    2010
    Posts
    1,022

    Re: conflict between auto save&close macro and show/hide sheets macro

    In the Case statement where you dont want to save add this line:
    ActiveWorkBook.Close, False
    It seemed to work for me.

    HTH
    Regards

    Rick
    Win7, Office 2010

  3. #3
    Registered User
    Join Date
    09-25-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: conflict between auto save&close macro and show/hide sheets macro

    no, it does not autosave before auto closing.

    If you open the file (enable macros), type something... and then wait 15 seconds, the workbook will close but it does NOT save.

    I need to know how to modify the code so that it will save before closing...

  4. #4
    Valued Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Eastlake Ohio
    MS-Off Ver
    2010
    Posts
    1,022

    Re: conflict between auto save&close macro and show/hide sheets macro

    When I learn to read, I will notice things like this;
    so that it will save before closing
    Regards

    Rick
    Win7, Office 2010

  5. #5
    Registered User
    Join Date
    09-25-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: conflict between auto save&close macro and show/hide sheets macro

    so... anyone has a solution to help fix this problem?

  6. #6
    Registered User
    Join Date
    07-06-2009
    Location
    Manchester, NH
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    38

    Re: conflict between auto save&close macro and show/hide sheets macro

    If it always needs to save when it closes, you can use the BeforeClose event, like this:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        
        ActiveWorkbook.Save
        
    End Sub
    It will always save before the close action. It should work whether its triggered from another procedure or by closing the window manually.

  7. #7
    Registered User
    Join Date
    09-25-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: conflict between auto save&close macro and show/hide sheets macro

    The macros I have already use a Workbook_BeforeClose.

    Anyhow it's not a solution since I don't want to force a save on a manual close of excel (maybe a user made a mistake that he does not want to save...).

    I want it to auto save only as part of the auto close macro.

    Any other ideas how I can make this work?

  8. #8
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: conflict between auto save&close macro and show/hide sheets macro

    See if this is any better
    Last edited by royUK; 10-18-2009 at 11:33 AM.
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  9. #9
    Registered User
    Join Date
    09-25-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: conflict between auto save&close macro and show/hide sheets macro

    Quote Originally Posted by royUK View Post
    See if this is any better
    sorry... I don't know what I should look at on that link...

  10. #10
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: conflict between auto save&close macro and show/hide sheets macro

    Sorry, I pasted the wrong link. It should be OK now
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  11. #11
    Registered User
    Join Date
    09-25-2009
    Location
    Romania
    MS-Off Ver
    Excel 2003
    Posts
    51

    Re: conflict between auto save&close macro and show/hide sheets macro

    The ForceUsersEnableMacros on your link is not working right for me.

    If I modify something on sheet2 or 3 and save, the first sheet becomes visible and sheet2 and 3 become hidden. So the save does not function your example of hide/show sheets.

    The macro in my example has this problem fixed using a custom save... which affects the save&close macro... and I hope someone can make them work together since I don't really know VB or excel programming...

+ 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.2.0