[VBA Userform] How to loop through all frames on a userform

smallxyz

Active Member
Joined
Jul 27, 2015
Messages
392
Office Version
  1. 2021
Platform
  1. Windows
I can't find a Frames collection in userform. How to loop through all frames on a UF?


Code:
    Dim c As MSForms.Controls
    For Each c In UTool.[COLOR=#ff0000]Controls[/COLOR]
        If TypeName(c) = "Frame" Then
            c.BorderStyle = fmBorderStyleNone
        End If
    Next


Thanks a lot!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
And what's wrong with the code you posted? You do have to iterate through the controls on the form and check the type/name of each one. Is this code not working?

WBD
 
Upvote 0
There is no such a command for c.BorderStyle = fmBorderStyleNone

This line work only if : Dim c As MSForms.Frame

However, there is no way to access to Frames collection, i.e. something like UTools.Frames
 
Last edited:
Upvote 0
Try this?

Code:
Dim c As MSForms.Control
Dim f As MSForms.Frame
For Each c In UTool.Controls
    If TypeName(c) = "Frame" Then
        Set f = c
        f.BorderStyle = fmBorderStyleNone
    End If
Next c

WBD
 
Upvote 0
The only thing wrong with the initial code is that it should be:

Rich (BB code):
Dim c As MSForms.Control

and not:

Rich (BB code):
Dim c As MSForms.Controls
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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