How to Resize Userform?

  • Thread starter Thread starter hce
  • Start date Start date
H

hce

Hi
Is it possible for one to resize an userform after it's activated?
Cheer
 
hce said:
Is it possible for one to resize an userform after it's activated?

Hi hce,

Yes. Just set the Width and Height properties of the UserForm to
whatever new values you want them to have.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
Hi hce,
In design mode, to place a label (lbl1) on the userform with the following
properties:
BackStyle = 0
ForeColor = &H80000010
Caption = "o"
Font.Name = "Marlett"
Font.Size = 12
Font.Bold = True
TextAlign = 3
AutoSize = True

In the UserForm module:
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 DrawMenuBar Lib "user32" (ByVal hWnd As Long) As
Long

Private Sub UserForm_Initialize()
UserForm_Resize
Dim hWnd As Long
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H84CC0080
DrawMenuBar hWnd
End Sub

Private Sub UserForm_Resize()
Me.lbl1.Top = Me.InsideHeight - Me.lbl1.Height
Me.lbl1.Left = Me.InsideWidth - Fix(Me.lbl1.Width)
End Sub

Regards,
MP
 
Rob,

I have used this technique for showing error frames and the like on the same
form, but have a small annoyance.

Have you ever had the problem when doing this that on some machines the
resized form shows all of the extra controls okay, but on others, parts get
clipped? If so, what was your solution?
 
I have had this issue also. Generally if rm is the control furthest to the
right, then I have set the forms scalewidth rm left + rm width plus a
margin of 64

hth
 
Hi Patrick,

That is the same sort of approach I tried, I just hoped for something more
scientific <vbg>
 
Hi Bob,

It sounds like Patrick has the same approach I use. Plenty of margin for
error. <g>

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top