Disabling the minimise button in Excel workbook

D

David

How can I prevent a user minimising the workbook?

I would also like to prevent them using the restore or
close buttons (I have a close option on a custom menu bar).

David
 
R

Romulus

This isn't simple. You need to create API calls to
control the way the OS draws the window containing the
worksheet. For that, you need to know the classname
Windows has for the type of window that is called by the
application to provide the UI. The classnames vary from
xl95, 97, 2K, and (afaik) XP. I can give you some
pointers - which version are you using?
 
S

Steve Garman

David said:
How can I prevent a user minimising the workbook?

Preventing it is difficult but you can immediately reverse it.

Private Sub Workbook_WindowResize(ByVal Wn As Window)
If Wn.WindowState = xlMinimized Then Wn.WindowState = xlMaximized
End Sub
I would also like to prevent them using the restore or
close buttons (I have a close option on a custom menu bar).

If what you want to do is to keep it maximized and open, try:

Global gbOkToClose As Boolean

Private Sub Workbook_WindowResize(ByVal Wn As Window)
Wn.WindowState = xlMaximized
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If gbOkToClose = False Then Cancel = True
End Sub

Obviously, you need to set gbOkToClose to True in your close button
 
D

David WIlliamson

Thanks Steve.

I would also like to prevent the user minimising or resizing the Excel
application window (or reverse the action).

Is this possible?

David

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
D

David WIlliamson

Thanks Romolus,

Would what you suggest prevent the user resizing the Excel application
window?

(I am now using Workbook_WindowResize with Wn.WindowState = xlMaximized
to trap and reverse an attempt to resize the workbook window.)

I am developing my appication with Excel 2002 and also preparing a
version for Excel 97.


Regards,
David

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Stephen Bullen

Hi David,
Would what you suggest prevent the user resizing the Excel application
window?

(I am now using Workbook_WindowResize with Wn.WindowState = xlMaximized
to trap and reverse an attempt to resize the workbook window.)

I am developing my appication with Excel 2002 and also preparing a
version for Excel 97.

In my opinion, you shouldn't attempt to control your users like this.
Instead, your application should respond appropriately to their choice of
window size and whether they want to close the application. Your users,
for example, may have vision impairments and need a large window and
large fonts to see what they're doing. Conversely, I may have a very
high-resolution monitor, and the last thing I want is for you to force
your application to take over the entire display. I may also want to go
and work on something else for a while, minimising your application to
the task bar while I'm doing that.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk
 

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

Similar Threads


Top