turning off minimize, maximize & close

G

Guest

I want to add a level of security to my file to force the file to auto close by macro only. I've added code to turn of the menus. Is there code I can include to turn off the three icons in the upper left corner; minimize, restor/maximize & close?

Thanks.

Kevin
 
L

Libby

Hi

Not sure about the minimise/maximise but you can disable
the close button by using a CloseSwitch variable

Public CloseSwitch

Sub Workbook_Open()
CloseSwitch = True 'set the switch to true
end sub

Sub Workbook Before_Close()
Select Case CloseSwitch
Case True
Cancel = True 'Workbook can't be closed
Case False
Cancel = False 'Workbook can be closed
End Select

Having set the CloseSwitch to True on opening the
workbook, the workbook can't be closed. Set the
CloseSwitch to False in your AutoClose macro and the
workbook will close.




-----Original Message-----
I want to add a level of security to my file to force the
file to auto close by macro only. I've added code to turn
of the menus. Is there code I can include to turn off the
three icons in the upper left corner; minimize,
restor/maximize & close?
 
G

Guest

Make that the three icons in the upper right corner.

----- Kevin wrote: -----

I want to add a level of security to my file to force the file to auto close by macro only. I've added code to turn of the menus. Is there code I can include to turn off the three icons in the upper left corner; minimize, restor/maximize & close?

Thanks.

Kevin
 
L

Libby

Kevin

under the project explorer double click on workbook
put the Public CloseSwitch under the declarations
set the CloseSwitch to true under the workbook_open event
and the select case in the workbook before_close event

None of it is in a module.

being public the CloseSwitch can be changed in other
procedures such as your macro
 
G

Guest

Thanks again Libby

I located the code as you instructed

Public CloseSwitc
Sub Workbook_Open(
CloseSwitch = Tru
End Su
Sub Workbook_Before_Close(
Select Case CloseSwitc
Case Tru
Cancel = True 'Workbook can't be close
Case Fals
Cancel = False 'Workbook can be close
End Selec

Note Workbook_Before_Close rather than Workbook Before_Close. Do I have it correct

However, the close switch continues to close the workbook

What should I do

Thanks

Kevi
----- Libby wrote: ----

Kevi

under the project explorer double click on workboo
put the Public CloseSwitch under the declaration
set the CloseSwitch to true under the workbook_open even
and the select case in the workbook before_close even

None of it is in a module

being public the CloseSwitch can be changed in other
procedures such as your macr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top