Loop through properties and values for controls on userform.

HighAndWilder

Well-known Member
Joined
Nov 4, 2006
Messages
606
Office Version
  1. 365
Platform
  1. Windows
Hi

I am able to loop through all Userforms and all Controls but I need to loop through all all of the properties
of each control.

Property and Properties seem to be data types according to Intellisense
in the VBA Editor but are not listed in the VBA data types list. Are these what I should be using?

Is there a way of using a variable to hold the property name and using this to find the value as I have a list
of all property names for each different control type?

Thanks for any pointers.

HighAndWild
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I'm sorry but I don't think that's possible to do.

A control doesn't have a 'collection' of properties that you could loop through, or use to refer to a property by name.

You could use CallByName to get the value of a property of a control, for example,
Code:
MsgBox CallByName(UserForm1.TextBox1, "Width", VbGet)
but if you wanted to get the values of all properties you would need lists of property names for each type of control
 
Upvote 0
Hi Norie

That is great.

I now loop through all loaded forms and each control in each of these forms and call the CallByName function with the control object and the property required.

I have a list of all properties for each control from https://bettersolutions.com/vba/controls/label.htm

I will now test it on forms with all control types.

I trust that the Beast From The East will not get you this weekend.
I'm on The Juarassic Coast so the beast was fairly tame down here last time!

Thanks.

HighAndWild
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top