Actual 'used' width of a form

  • Thread starter Thread starter robert.waters
  • Start date Start date
R

robert.waters

Does anyone have a code resource for determining the actual used width
of a form?
I would like to know the minimum width that a form can have without
hiding any of it's controls/subforms.
 
You could loop thru all the controls on the form and add the control's left
and width properties, which will give you the right most number of the
control (in twips). You could store results in an array and find the
largest number, which would be the fartherest right point of a control. I
am winging it here, don't have any code other than a

Debug.Print Me![somecontrol].Left + Me![somecontrol].Width

HTH get you started
Damon
 
Loop through the Controls collection, and find the largest values of Left +
Width for the form:

Dim ctlCurr As Control
Dim lngMaxSize As Long

For Each ctlCurr In Me.Controls
With ctlCurr
If .Left + .Width > lngMaxSize Then
lngMaxSize = .Left + .Width
End If
End With
Next ctlCurr

MsgBox "The form needs to be at least " & _
lngMaxSize & " twips."
 

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