LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default Disable Minimize/Maximize button for Excel 2007 Application

I am trying to prevent a workbook I made from being minimized/maximized by
the user. I have command buttons to do that and I want to force them to use
the command buttons. The code below disables the min/max application buttons
in Excel 2003, but it only disables the close button in Excel 2007. It also
disables dragging to resize the application window in 2007, but that doesn't
help me. I need to disable the min/max button and it needs to work in Excel
2007. Any suggestions?

Thanks

Steve

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, _
ByVal bRevert As Integer) As Integer

Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Integer, _
ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer

'The following procedure disables the Control menu.
Sub Disable_Control()
Dim X As Integer, hwnd As Long
hwnd = FindWindow("XLMain", Application.Caption)
For X = 1 To 9
'Delete the first menu command and loop until
'all commands are deleted
Call DeleteMenu(GetSystemMenu(hwnd, False), 0, 1024)
Next X
End Sub

'The following procedure restores the Control menu.
'Note that to run this procedure, the Declare statements above
'must be in the module.
Sub RestoreSystemMenu()
Dim hwnd As Long
'Get the window handle of the Excel application.
hwnd = FindWindow("xlMain", Application.Caption)
'Restore system menu to original state.
hMenu% = GetSystemMenu(hwnd, 1)
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i minimize/maximize a workbook from vba? I want to minimize it durring processing to speed things up a bit Daniel Excel Worksheet Functions 2 July 9th 05 03:35 AM
Disable Close X Button On Excel Application Celtic_Avenger[_57_] Excel Programming 2 October 31st 04 04:02 PM
Maximize & Minimize where are you ? Don Bowyer Excel Programming 2 July 18th 04 02:41 PM
Minimize/Maximize excel restores command bars Rockee052[_53_] Excel Programming 3 March 3rd 04 12:27 AM
Maximize minimize and restore button No Name Excel Programming 1 October 27th 03 03:14 PM


All times are GMT +1. The time now is 09:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"