+ Reply to Thread
Results 1 to 6 of 6

preventing accidental file closure

  1. #1
    Forum Contributor
    Join Date
    03-12-2018
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    118

    preventing accidental file closure

    Dear forum
    I have a macro that closes and saves a file. I would like to see if it's possible to find a way that I cannot close the file/window with the X in the top right X button - so that the only way to close that particular file, if open, is to use the macro I've created. Is it possible? thank you for your help!

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: preventing accidental file closure

    That is Simple when you know how.

    In the Workbooks, "ThisWorkbook" Macro module there is an option:

    Please Login or Register  to view this content.
    Change that to:

    Please Login or Register  to view this content.
    You can never close the Workbook.

    Declare a Global Variable CloseFlag as Boolean. Set that to True using your Macro and use the code:

    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-02-2020 at 08:49 AM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    03-12-2018
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    118

    Re: preventing accidental file closure

    Hello mehmetcik thanks for that.
    I think that would work, but I guess I need to give you a couple more information.

    I have a file, called RUMDOM.xlsm
    This is the file I've always open on the background and where the macros to Open and Close file Guide.xlsx.
    Guide file cannot be a macro enabled file.

    However, Guide.xlsx is the only file that I have to make sure I only close by launching the macro from RUMDOM file. Am I making sense?

    Would that work also if Guide cannot be .xlsm?

    Is it something that I can add in the OPEN macro that CLOSE macro will then remove before Guide.xlsx is saved and closed?

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: preventing accidental file closure

    There is a possible mechanism that might work.

    I will have a look at this and get back to you.

    Ok this works.
    The CloseGuide macro writes in Cell A1 of Sheet(1) of Guide.

    Please Paste the "Guide" macro inside a frequently used Macro in Rumdom [ But not too Frequently ]. Is can even be inside a sheet spefic macro.
    Like: Worksheet: Change, Selection_Change, Activate etc.

    You could even create a Workbook Open Macro inside Rumdom that opens "Guide.xlsx" and then runs the Guide Macro.
    In fact that is the route I would take.

    Please Login or Register  to view this content.



    Please Login or Register  to view this content.
    Last edited by mehmetcik; 03-03-2020 at 10:41 AM.

  5. #5
    Forum Contributor
    Join Date
    03-12-2018
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    118

    Re: preventing accidental file closure

    thank you, I will review this later today or tomorrow and let you know.

  6. #6
    Forum Contributor
    Join Date
    03-12-2018
    Location
    London, England
    MS-Off Ver
    2016
    Posts
    118

    Re: preventing accidental file closure

    thank you for this!

+ 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: 4
    Last Post: 03-09-2018, 01:12 PM
  2. Replies: 3
    Last Post: 01-29-2018, 11:34 AM
  3. Preventing that accidental Reply All, any add-ins or Macros?
    By taylorsm in forum Outlook Formatting & Functions
    Replies: 3
    Last Post: 11-09-2016, 04:06 AM
  4. Preventing accidental deletion of text
    By pacoppen in forum Excel General
    Replies: 1
    Last Post: 03-02-2015, 09:43 AM
  5. Preventing accidental change of a check box
    By Research RN in forum Access Tables & Databases
    Replies: 1
    Last Post: 09-25-2009, 03:07 PM
  6. [SOLVED] Preventing an Excel file from being saved
    By Hall in forum Excel General
    Replies: 8
    Last Post: 04-26-2006, 08:45 PM
  7. [SOLVED] (Leo) preventing MDI file to be opened
    By Leo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-14-2005, 03:05 AM

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