Discussion Locked

VBA/Excel: Close Methods

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

As you know, there are three standard buttons that are placed at the top of User Forms. They are the minimize, maximize, and close. Is there a way that I can disable that close button? I want my users to only be able to close using the button I provide because I would like to do more than close the form when they're done using it.

Can anyone help??

7 replies

by dklippert

Something like:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Range("a1") = 1 Then Cancel = True
End Sub

by cbdepadua

Thank you for your tip but I'm not looking for something to run as the workbook closes. Instead I want it to run when my form is closed.

by ananthap

Apart from finding the concerned Excel object, you could code your task in the "Auto_close" function. This will "fire" whichever way you close. Even if you have closed with no changes!.

HTH.
End of mail

by cbdepadua

Doesn't the "Auto_Close" fire when you are closeing the workbook? I need something to fire as the form closes and the workbook remains open.

This discussion is closed to new replies.