#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Form Resize

I can't seem to find a way to make a form resizable in VBA. Anyone out
there with an idea... or can point out my stupidity?

Thanks

Suzette


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Form Resize

Suzette,

Not sure what you want, but this will size the form to fit the entire screen

Private Sub UserForm_Initialize()
With Application
Me.Top = .Top
Me.Left = .Left
Me.Height = .Height
Me.Width = .Width
End With
End Sub

--
sb
"Suzette" wrote in message
...
I can't seem to find a way to make a form resizable in VBA. Anyone out
there with an idea... or can point out my stupidity?

Thanks

Suzette




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Form Resize

Hi Suzette,

UserForms are not as customizable as VB Forms, so you can't make them
sizable without using API calls. There's an example of how to do it on
Stephen Bullen's site:

http://www.bmsltd.co.uk/Excel/SBXLPage.asp [formfun.zip]

--
Regards,

Jake Marx
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


Suzette wrote:
I can't seem to find a way to make a form resizable in VBA. Anyone
out there with an idea... or can point out my stupidity?

Thanks

Suzette


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Form Resize

Hi

There is a freeware control available at www.VBusers.com that will allow
you to resize a VBA form and all controls on it with minimal code.
Look for FlexGrabberE in the downloads section.

HTH

Ken

"Suzette" wrote in message
...
I can't seem to find a way to make a form resizable in VBA. Anyone out
there with an idea... or can point out my stupidity?

Thanks

Suzette





---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.530 / Virus Database: 325 - Release Date: 22/10/2003


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Form Resize

Really nice little tool!!!

I'm looking for a bit of help though. I've used the following code and
it does what I am looking for. However on my userform I have 75 labels,
45 checkboxes, 50 Textboxes, 4 multipages and 9 frames. How can I write
the code in such a way that I can modify the size of each element, but
without the need to list each element separately within the code.
Apologies if this is a rather simple question, but I'm only recently
started using VBA.

Private Sub FlexGrabberE1_ResizeComplete(WidthFactor As Single,
HeightFactor As Single)

With Me
With .Label1
..Left = .Left * WidthFactor
..Width = .Width * WidthFactor
..Top = .Top * HeightFactor
..Height = .Height * HeightFactor
End With
With .MultiPage1
..Left = .Left * WidthFactor
..Width = .Width * WidthFactor
..Top = .Top * HeightFactor
..Height = .Height * HeightFactor
End With
With .TextBox1
..Left = .Left * WidthFactor
..Width = .Width * WidthFactor
..Top = .Top * HeightFactor
..Height = .Height * HeightFactor
End With
End With

End SubKen Macksey wrote:
*Hi

There is a freeware control available at www.VBusers.com that will
allow
you to resize a VBA form and all controls on it with minimal code.
Look for FlexGrabberE in the downloads section.

HTH

Ken

*



---
Message posted from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Form Resize

Alan,
Here's how I would do it:

Sub ChangeControlSize(WidthFactor As Single, HeightFactor As Single)

Dim ctl As Control
For Each ctl in UserForm1
ctl.Left = ctl.Left * WidthFactor
ctl.Width = ctl.Width * WidthFactor
ctl.Top = ctl.Top * HeightFactor
ctl.Height = ct.Height * HeightFactor
Next
End Sub

Then shrink the User Form itself by applying the Width and Height factors to
it.

-- Dennis Eisen
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Form Resize

Try:

Private Sub FlexGrabberE1_ResizeComplete(WidthFactor As Single,
HeightFactor As Single)
Dim oControl As Control
For Each oControl In Me.Controls
Select Case TypeName(oControl)
Case "Label"
oControl.Left = oControl.Left * WidthFactor
oControl.Width = oControl.Width * WidthFactor
oControl.Top = oControl.Top * HeightFactor
oControl.Height = oControl.Height * HeightFactor
Case "CommandButton"
oControl.Top = Me.InsideHeight - oControl.Height - 3
End Select
Me.Repaint
Next
End Sub

PS. I have updated the download to include this code

regards,
andrew baker
www.vbusers.com


Alan T wrote in message ...
Really nice little tool!!!

I'm looking for a bit of help though. I've used the following code and
it does what I am looking for. However on my userform I have 75 labels,
45 checkboxes, 50 Textboxes, 4 multipages and 9 frames. How can I write
the code in such a way that I can modify the size of each element, but
without the need to list each element separately within the code.
Apologies if this is a rather simple question, but I'm only recently
started using VBA.

Private Sub FlexGrabberE1_ResizeComplete(WidthFactor As Single,
HeightFactor As Single)

With Me
With .Label1
.Left = .Left * WidthFactor
.Width = .Width * WidthFactor
.Top = .Top * HeightFactor
.Height = .Height * HeightFactor
End With
With .MultiPage1
.Left = .Left * WidthFactor
.Width = .Width * WidthFactor
.Top = .Top * HeightFactor
.Height = .Height * HeightFactor
End With
With .TextBox1
.Left = .Left * WidthFactor
.Width = .Width * WidthFactor
.Top = .Top * HeightFactor
.Height = .Height * HeightFactor
End With
End With

End SubKen Macksey wrote:
*Hi

There is a freeware control available at www.VBusers.com that will
allow
you to resize a VBA form and all controls on it with minimal code.
Look for FlexGrabberE in the downloads section.

HTH

Ken

*



---
Message posted from http://www.ExcelForum.com/

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Form Resize

Hi Suzette:

Alternatively, try the following API-based routine:

Option Explicit

Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As _
Any) As Long

Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTBOTTOMRIGHT = 17
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
_
lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub UserForm_MouseDown(ByVal Button As Integer, ByVal Shift As _
Integer, ByVal X As Single, ByVal Y As Single)
Dim lngHwnd As Long
If X = Me.Width - 10 Then
If Y = Me.Height - 30 Then
lngHwnd = FindWindow(vbNullString, Me.Caption)
ReleaseCapture
SendMessage lngHwnd, WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, ByVal 0&
End If
End If
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As _
Integer, ByVal X As Single, ByVal Y As Single)
If X = Me.Width - 10 Then
If Y = Me.Height - 30 Then
Me.MousePointer = fmMousePointerSizeNWSE
'Unfortunately, in Excel 2002, the pointer doesn't change shape until
after you click the
'bottom right-hand corner of the UserForm. It worked just fine in Excel
97.
End If
Else
Me.MousePointer = fmMousePointerDefault
End If
End Sub

Regards,

Vasant.


"Suzette" wrote in message
...
I can't seem to find a way to make a form resizable in VBA. Anyone out
there with an idea... or can point out my stupidity?

Thanks

Suzette




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resize Check Box on Form Toolbar Sandra Excel Discussion (Misc queries) 2 January 17th 08 07:15 PM
How to resize Data, form with current wksht information RennieMay Excel Worksheet Functions 1 July 13th 07 09:22 AM
How do I resize a check box form object in Excel? bpoole Excel Discussion (Misc queries) 1 May 11th 06 06:38 PM
I could NOT resize the axis title but excel allows me to resize gr Iwan Setiyono Ko Charts and Charting in Excel 0 March 15th 06 10:34 AM
How to resize Data Form dialog window? Compucat Excel Worksheet Functions 1 June 8th 05 11:24 PM


All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"