View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default What is the Limit of Text Boxes & Labels a User Form can have?

Peter,
Thanks very much for that behind the scenes work and analysis. I'll confer
with Brian to determine a new approach that's acceptable to him.

What I have in mind is to simply split the 4 pages into 4 userforms, with
one acting as a main and the other 3 set up so that they are opened
automatically when the main opens, and prevented from closing except when the
main is closed. All that would be needed would be buttons on each to allow
the selection of one of the others when it is needed to be used.

Seems kind of odd that MSFT doesn't seem to have any published limits
regarding size, content, or number of controls on UserForms.

"Peter T" wrote:

"Total of 1,636 controls on the multipage"
That is a lot, and probably strong candidate for a different design approach
even without the memory error.

In a very light test it looks like there's an absolute limit of not much
more than 1200 controls on a multipage. Try this -

Add a multipage with 3 pages to a new userform. Size the Multipage to about
700x400 and the form to suit. Leave a small gap between the caption and the
top of the multipage. Also ensure Trust Access to VBProject is enabled in
security settings.

Sub design1()
Dim i&, n&, r&, c&, k&, t&
Dim p As Page
Dim u As UserForm
Dim tbx As MSForms.TextBox

Set u = ThisWorkbook.VBProject.VBComponents("UserForm1").D esigner
n = u.Controls.Count - 1
For i = n To 1 Step -1
u.Controls.Remove u.Controls(i).Name
Next

For Each p In u.Controls("MultiPage1").Pages

For r = 0 To 20 - 1
For c = 0 To 20 - 1
t = t + 1
Set tbx = p.Controls.add("Forms.TextBox.1")
With tbx
.Left = c * 33
.Top = r * 15
.Width = 33
.Height = 15
.Text = r + 1 & ":" & c + 1
End With
Next
Next
Next

u.Caption = "Controls: " & t
End Sub

For me 3x20x20 = 1200 was OK, but I couldn't increase a 20 to 21 and go on
to load the form.

Regards,
Peter T


"JLatham" wrote in message
...
See my post in response to OssieMac above - total of 1,636 controls of all
types on the 4 pages (1049 on the 1st 3, another 587 on the 4th), plus
there
is a small graphic of a company logo on each of those 4 pages in the
MultiPage control (could explain the frx file size).

"Peter T" wrote:

The 64K was never a limit set in stone, in any case you've only got 34k.
I've tested forms with 1000+ controls without problems but 219K in the
frx
does seem large (but depends more on what it is, eg definition of a
picture
would make it large but merely basic control properties doesn't take
much).
When you say "a lot" of controls what are you actually talking about.

Regards,
Peter T


"Brian" wrote in message
...
What is the Max File Size a User Form can be?

I have Windows 7 with Office 2007.

Does it have like a 64K limit?

The file size as far as kb. My entire Program is 1,203 Kb.

When I ran it I got a "compile Error out of memory", so I exported my
User
Form. Then I looked at the file size of just the User Form in a blank
Workbook
34 KB = .frm
219 KB = frx

My user Form is a Multi Page with 4 Pages on it. There are alot of text
boxes and labels on the 4 sheets. Is there a limit to the number of
text
boxes & labels you can have in a user Form?

I have 12 GB of Memory, so how can I run out?





.



.