Excel - Bloquear botones cerrar, minimizar y maximizar x64

 
Vista:
sin imagen de perfil
Val: 5
Ha aumentado su posición en 9 puestos en Excel (en relación al último mes)
Gráfica de Excel

Bloquear botones cerrar, minimizar y maximizar x64

Publicado por Julen (5 intervenciones) el 27/11/2017 10:58:48
Buenos días a todos;

Antes de nada, pedir perdón si existe ya algún post relacionado, pero solo he encontrado cosas relacionadas con los UserForm.

Pues bien, necesito darle un apariencia distinta a la que ofrece Excel predeterminadamente. Ahora mismo lo tengo todo deshabilitado (Menús) dejando solo la barra de título, a la que le he quitado el icono y cambiado los nombres centrales, pero me falta quitar los botones. He conseguido que funcione en Excel 32 bits, y lo necesito en 64, cosa que no logro. Necesito unas librerías concretas.

En el caso de 32 bits este es el código, este código me lo cedió un compañero de trabajo (con el que no puedo contactar de nuevo, no se si es suyo o no):

Gracias de antemano por si podemos sacarlo entre todos, Un saludo!!

Módulo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Option Explicit
 
Public Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
 
Public Const MF_BYPOSITION = &H400&
Public Const MF_REMOVE = &H1000&
 
Public blnCerrar As Boolean
 
'--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Public Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
 
Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
 
Public Declare Function DrawMenuBar _
Lib "user32" _
(ByVal hWnd As Long) As Long
 
Public Declare Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" _
(ByVal hWnd1 As Long, _
ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long
 
Public Const WS_SYSMENU = &H80000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000
Public Const GWL_STYLE = (-16)
 
Sub EnableControlBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
 
hWnd = Application.hWnd
 
CurStyle = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_SYSMENU) Then
CurStyle = CurStyle Or WS_SYSMENU
End If
Else
If (CurStyle And WS_SYSMENU) = WS_SYSMENU Then
CurStyle = CurStyle - WS_SYSMENU
End If
End If
Call SetWindowLong(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)
 
End Sub
 
Sub EnableMinimizeBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
 
hWnd = Application.hWnd
 
CurStyle = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_MINIMIZEBOX) Then
CurStyle = CurStyle Or WS_MINIMIZEBOX
End If
Else
If (CurStyle And WS_MINIMIZEBOX) = WS_MINIMIZEBOX Then
CurStyle = CurStyle - WS_MINIMIZEBOX
End If
End If
Call SetWindowLong(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)
 
End Sub
 
Sub EnableMaximizeBox(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
 
hWnd = Application.hWnd
 
CurStyle = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_MAXIMIZEBOX) Then
CurStyle = CurStyle Or WS_MAXIMIZEBOX
End If
Else
If (CurStyle And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX Then
CurStyle = CurStyle - WS_MAXIMIZEBOX
End If
End If
Call SetWindowLong(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)
 
End Sub
 
 
Function hWorkbook() As Long
Dim hDesk As Long
Dim hWBook As Long
 
hDesk = FindWindowEx(Application.hWnd, 0&, "XLDESK", vbNullString)
If hDesk Then
hWBook = FindWindowEx(hDesk, 0&, "EXCEL7", vbNullString)
hWorkbook = hWBook
End If
 
End Function
 
 
Sub EnableControlBoxWB(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
 
hWnd = hWorkbook
 
CurStyle = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_SYSMENU) Then
CurStyle = CurStyle Or WS_SYSMENU
End If
Else
If (CurStyle And WS_SYSMENU) = WS_SYSMENU Then
CurStyle = CurStyle - WS_SYSMENU
End If
End If
Call SetWindowLong(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)
 
End Sub
 
 
Sub EnableMinimizeBoxWB(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
 
hWnd = hWorkbook
 
CurStyle = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_MINIMIZEBOX) Then
CurStyle = CurStyle Or WS_MINIMIZEBOX
End If
Else
If (CurStyle And WS_MINIMIZEBOX) = WS_MINIMIZEBOX Then
CurStyle = CurStyle - WS_MINIMIZEBOX
End If
End If
Call SetWindowLong(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)
 
End Sub
 
 
Sub EnableMaximizeBoxWB(Enable As Boolean)
Dim CurStyle As Long
Dim hWnd As Long
 
hWnd = hWorkbook
 
CurStyle = GetWindowLong(hWnd, GWL_STYLE)
If Enable Then
If Not (CurStyle And WS_MAXIMIZEBOX) Then
CurStyle = CurStyle Or WS_MAXIMIZEBOX
End If
Else
If (CurStyle And WS_MAXIMIZEBOX) = WS_MAXIMIZEBOX Then
CurStyle = CurStyle - WS_MAXIMIZEBOX
End If
End If
Call SetWindowLong(hWnd, GWL_STYLE, CurStyle)
Call DrawMenuBar(hWnd)
 
End Sub



En el ThisWorkBook:

1
2
3
4
5
6
7
8
9
EnableControlBox False
EnableMinimizeBox False
EnableMaximizeBox False
 
ActiveWindow.WindowState = xlMaximized
 
EnableControlBoxWB False
EnableMinimizeBoxWB False
EnableMaximizeBoxWB False
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder