ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   adding components in VBA (https://www.excelbanter.com/excel-programming/296997-adding-components-vba.html)

chrisdarl[_10_]

adding components in VBA
 
Hi, is there a way that i can add text boxs and labels to my userfor
using coding instead of just using the toolbox?

Can this be done? thanks chris

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


Chip Pearson

adding components in VBA
 
Chris,

Yes, it can be done. The changes are temporary, though; the
control will disappear when the form is unloaded. For example,
the following will add a text box to Userform1.

Dim TBX As MSForms.TextBox
With UserForm1.Controls
Set TBX = .Add(bstrprogid:="Forms.TextBox.1", _
Name:="MyTextBox", Visible:=True)
TBX.Top = 50
TBX.Left = 100
End With
UserForm1.Show


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"chrisdarl " wrote in
message ...
Hi, is there a way that i can add text boxs and labels to my

userform
using coding instead of just using the toolbox?

Can this be done? thanks chris.


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




Bob Phillips[_6_]

adding components in VBA
 
Alternative approach is to add them at design time, but hide them until you
need them.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"chrisdarl " wrote in message
...
Hi, is there a way that i can add text boxs and labels to my userform
using coding instead of just using the toolbox?

Can this be done? thanks chris.


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




Tom Ogilvy

adding components in VBA
 
Here is another source of information:

http://j-walk.com/ss/excel/tips/tip76.htm
Creating a UserForm Programmatically

or the parent page:
http://j-walk.com/ss/excel/tips/userformtips.htm

at John Walkenbach's site

--
Regards,
Tom Ogilvy


"chrisdarl " wrote in message
...
Hi, is there a way that i can add text boxs and labels to my userform
using coding instead of just using the toolbox?

Can this be done? thanks chris.


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





All times are GMT +1. The time now is 04:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com