LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default User Form Display Question

My problem is that the User Form is to big to fit on the Screen. It works
good on 1 Computer, but when I use A computer with a smaller Screen it
becomes way to big. When that happens 30% of the Form is cut off.

Is there a code that I can run on UserForm_Initialize that will size it for
the Screen. It would be nice if it would size according to the Display
settings.

I found this code here in the forumn but I can't get it to work.

Sub size_form_and_controls()

Dim start_height As Long
Dim start_width As Long
Dim new_height As Long
Dim new_width As Long
Dim height_ratio As Double
Dim width_ratio As Double
Dim ctl As Control

With Me
'default settings on your computer
start_height = 1024
start_width = 1280
'find current screen resolution
new_height = Application.Height
new_width = Application.Width
'ratio to apply to form and all Controls
height_ratio = new_height / start_height
width_ratio = new_width / start_width
'resize the whole form
.Height = new_height
.Width = new_width
'resize the controls and text
For Each ctl In .Controls
ctl.Top = ctl.Top * height_ratio
ctl.Left = ctl.Left * width_ratio
ctl.Height = ctl.Height * height_ratio
ctl.Width = ctl.Width * width_ratio
'if control has no font then skip
On Error Resume Next
ctl.Font.Size = ctl.Font.Size * height_ratio
On Error GoTo 0
Next ctl
End With
 
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
display a user form WBTKbeezy Excel Programming 0 June 2nd 06 08:41 PM
user form question: text box to display result BigPig Excel Discussion (Misc queries) 0 February 28th 06 12:33 AM
user form question: text box to display result BigPig Excel Worksheet Functions 0 February 25th 06 08:17 PM
How to display =x/y result in a user form AndyRoo Excel Programming 2 November 25th 05 02:41 PM
User Form to display more than 1 reslut EstherJ Excel Programming 1 August 23rd 04 01:40 PM


All times are GMT +1. The time now is 11:13 PM.

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"