eliminate min max and close......

polska2180

Active Member
Joined
Oct 1, 2004
Messages
384
Office Version
  1. 365
buttons at the top of the work book.

In other words is there a way to hide them?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
not sure if you can do it on an application level, but you could do it on a workbook level like this.

Code:
Sub Macro1()
    ActiveWorkbook.Protect Structure:=False, Windows:=True
End Sub

If you want to password it then do
ActiveWorkbook.Protect Structure:=False, Windows:=True, Password:="whatever"
 
Upvote 0
Okay for the Max and Min I got

Private Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) _
As Long

Const WS_MINIMIZEBOX = &H20000
Const WS_MAXIMIZEBOX = &H10000
Const GWL_STYLE = (-16)

Sub HideMinimizeAndMaximizeButtons()

Dim L As Long

L = GetWindowLong(Application.hwnd, GWL_STYLE)
L = L And Not (WS_MINIMIZEBOX)
L = L And Not (WS_MAXIMIZEBOX)
L = SetWindowLong(Application.hwnd, GWL_STYLE, L)

End Sub

Sub RestoreMinimizeAndMaximizeButtons()

Dim L As Long
L = GetWindowLong(Application.hwnd, GWL_STYLE)
L = SetWindowLong(Application.hwnd, GWL_STYLE, WS_MINIMIZEBOX _
Or WS_MAXIMIZEBOX Or L)

End Sub

Which works

HOWEVER FOR CLOSE BUTTON I HAVE

The following code, posted by Raider, successfully disables the famous (X) close button at the top right corner of the Excel window. What changes to this code would I make to disable the Minimize or Maximize buttons at the top right corner of the Excel 2000 Window?

Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub Workbook_Open()
Dim MyHandle
Dim hWnd As Long
MyCap$ = Application.Caption
hWnd = FindWindowA(vbNullString, MyCap$)
MyHandle = GetSystemMenu(hWnd, 0)
Call RemoveMenu(MyHandle, 6, &H400)
End Sub

WHICH I GOT

=CLICK

THE PROBLEM IS I DONT KNOW HOW TO RESTORE THE CLOSE.

TY
 
Upvote 0
Code:
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub Restore_Close()
Dim hWnd As Long
MyCap$ = Application.Caption
hWnd = FindWindowA(vbNullString, MyCap$)
Call GetSystemMenu(hWnd, 6)
End Sub
 
Upvote 0
I changed the code from 0 to 1 and that worked

Private Sub Workbook_Open()
Dim MyHandle
Dim hWnd As Long
MyCap$ = Application.Caption
hWnd = FindWindowA(vbNullString, MyCap$)
MyHandle = GetSystemMenu(hWnd, 1)
Call RemoveMenu(MyHandle, 6, &H400)
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top