Ajustar tamaño de userform a pantalla

Me podrían ayudar con el código VB (excel) para que las UserForm de mi proyecto se adapten al tamaño de la pantalla del usuario que la utilice.

Abrazos.

1

1 respuesta

Respuesta
1

Option ExplicitConst ENUM_CURRENT_SETTINGS As Long = -1&Const CCDEVICENAME = 32Const CCFORMNAME = 32Private Type DEVMODEdmDeviceName As String * CCDEVICENAMEdmSpecVersion As IntegerdmDriverVersion As IntegerdmSize As IntegerdmDriverExtra As IntegerdmFields As LongdmOrientation As IntegerdmPaperSize As IntegerdmPaperLength As IntegerdmPaperWidth As IntegerdmScale As IntegerdmCopies As IntegerdmDefaultSource As IntegerdmPrintQuality As IntegerdmColor As IntegerdmDuplex As IntegerdmYResolution As IntegerdmTTOption As IntegerdmCollate As IntegerdmFormName As String * CCFORMNAMEdmUnusedPadding As IntegerdmBitsPerPel As IntegerdmPelsWidth As LongdmPelsHeight As LongdmDisplayFlags As LongdmDisplayFrequency As LongEnd TypePrivate Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Private Sub UserForm_Initialize()
Dim Ajuste As Integer
Me.StartUpPosition = 0Me.Top = 0Me.Left = 0Dim DevM As DEVMODECall EnumDisplaySettings(0&, ENUM_CURRENT_SETTINGS, DevM)
Ajuste = 24 'En mi caso es 24, peropuede ser 16, o 32, tú prueba
Me.Width = DevM.dmPelsWidth / DevM.dmBitsPerPel * AjusteMe.Height = DevM.dmPelsHeight / DevM.dmBitsPerPel * Ajuste
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas