Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 09-29-2021, 12:15 PM
Purfleet Purfleet is offline Message to Protect Sheet after a command Windows 10 Message to Protect Sheet after a command Office 2019
Expert
 
Join Date: Jun 2020
Location: Essex
Posts: 345
Purfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to beholdPurfleet is a splendid one to behold
Default

as logit has said the beforeClose thisworkbook is ideal for what you want, but you dont need to ask the user to do anything.

If you open the this workbook Module in the VBA editor you will see drop downs at the top the one on the left (general) can be changed to Workbook (it acts when the workbook does something).

The one on the right is the thing that happens - there is quite a few, but some are really obvious like BeforeClose.

Select BeforeClose and a automated Private Sub will open called Workbook_BeforeClose

In between the 2 lines put in anythng you want to happen before the workbook is closed, for example

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

    ActiveWorkbook.Save
    Worksheets("Form").Protect
    
End Sub
Be careful with the Activeworkbook.save though because if the user does something stupid like delete all the data and then they close it because they panic it will save with all the data lost
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command button. To multi command Taylormations Word VBA 11 09-14-2020 02:39 AM
How do I un-protect docs I didn't protect? doctorduncan Word 4 05-30-2019 11:09 AM
Message to Protect Sheet after a command Outlook 2013 > Command to view the header without opening a suspicious message? Macintosh Outlook 2 02-04-2019 05:38 PM
Show table list by using chek box command and save document on sharepoint by using command button Zhibek Word VBA 3 08-16-2018 06:19 PM
Repair command results in error message srdiamond Office 0 03-01-2011 12:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:39 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft