¿Cuál es el código para que aparezcan los botones de minimizar y maximizar en un Userform de VBA 2013?

He probado con un código que aparece en todas las páginas de internet, que es el siguiente:

Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const GWL_STYLE As Long = (-16)
Private Sub UserForm_Initialize()
Dim lngMyHandle As Long, lngCurrentStyle As Long, lngNewStyle As Long
'Obtenemos el "Handle" del Userform
lngMyHandle = FindWindow("THUNDERDFRAME", Me.Caption)
'Obtenemos el estilo actual del UserForm
lngCurrentStyle = GetWindowLong(lngMyHandle, GWL_STYLE)
'Creamos un nuevo estilo de titulo con los botones deseados
lngNewStyle = lngCurrentStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
'Aplicamos las nuevas propiedades al UserForm
SetWindowLong lngMyHandle, GWL_STYLE, lngNewStyle
End Sub

Y NO HAY CASO, ¿quién puede ayudarme por favor? Lo necesito!

1 Respuesta

Respuesta
3

H o l a:

Consulta el siguiente enlace, tiene un código para las versiones de 32 y 64 bits y para Excel 2013.

http://blogs.itpro.es/exceleinfo/2014/10/23/hacer-macros-compatibles-con-excel-de-32-y-64-bits/ 

Yo he probado esta opción y me funciona:

Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
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
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const GWL_STYLE As Long = (-16)
Private Const WS_SYSMENU As Long = &H80000 'variable para ocultar el botón x
'
Private Sub UserForm_Initialize() ' Declaración de variantes para los botones de maximizar y minimizar
    Dim lngMyHandle As Long, lngCurrentStyle As Long, lngNewStyle As Long
    If Application.Version < 9 Then
        lngMyHandle = FindWindow("THUNDERXFRAME", Me.Caption)
    Else
        lngMyHandle = FindWindow("THUNDERDFRAME", Me.Caption)
    End If
    lngCurrentStyle = GetWindowLong(lngMyHandle, GWL_STYLE)
    lngNewStyle = lngCurrentStyle Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
    SetWindowLong lngMyHandle, GWL_STYLE, lngNewStyle
    Dim hWnd As Long 'para ocultar el botón "X"
    Dim lngWstyle As Long
End Sub

Sal u dos

¡Gracias! Pero no hay caso, no me funciona con ningún código que me enviaste, usas Excel 2013? 

¿Revista todo el código que viene en el enlace?

Tengo versión 2007, pero en el enlace que te envié habla sobre las versiones.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas