Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable close button on worksheet 1

Status
Not open for further replies.

MatthewGB

Programmer
Oct 22, 2002
39
AU
Hi,
Does anyone know how to diable the close button on a worksheet? I know how to do this for a userform, but I am not sure whether the same method can be applied to a worksheet, and also for the workbook.

Thanks

Matt
 
Hiya,

perhaps this'll do:
choose TOOLS > PROTECTION > WORKBOOK, and check option WINDOWS only. Plz note - that'll remove ALL system items from the window


HTH

Cheers
Nikki
 
Thanks for the quick reply Nikki. That was exactly what i was looking for. Doing it with code was also pretty straightforward, so workbook protection can be turned on when opening the workbook, and off when its closed.

A big star for you!

Cheers
Matt
 
Matthew,

Can you tell me how you disable the close control on a userform? Thanks.
 
Hiya,

just use the QueryClose event of the userform:
Code:
Private Sub UserFormName_QueryClose(Cancel As Integer, CloseMode As Integer)
  If CloseMode = 0 Then Cancel = True
End Sub

HTH

Cheers
Nikki
 
Nikita, does the query_close method differ from the terminate method?
 
Hi tomreid,

the 2 events are triggered at different moments. The whole list of event & their order:
QueryClose is triggered when the userform is being closed but is sitll available in memory
Terminate is triggered when the userform pbject is set to nothing i.e. is kicked out of memory

Cheers
Nikki
 
Nikki,
You beat me to it!
That is the method I also use to disable the close button.
Once again, thanks for all your help with this problem and the problem in my other thread regarding the SaveAs function in Word.

Cheers
Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top