VBA, Grey Out All the Controls (Checkboxes, OptionBoxes etc) within a Frame

New_Alex
New_Alex used Ask the Experts™
on
Hi Guys.

I am working with the Word VBA control tools and I have constructed a Form which is sectioned with frames.

I am looking for a simple code that will grey out all the Controls that Exist within any single Frame.....

Any ideas?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Retired
Top Expert 2012
Commented:
Is this simple enough?
Dim ctl As Control
    
    For Each ctl In Frame1.Controls
        ctl.Enabled = False
    Next ctl

Open in new window

Most Valuable Expert 2011
Top Expert 2011
Commented:
Something like:
Sub EnableControls(frm As MSForms.Frame, blnEnable As Boolean)
   Dim ctl As MSForms.Control
   For Each ctl In frm.Controls
      ctl.Enabled = blnEnable
   Next ctl
End Sub

Open in new window


called like this (to disable; to enable, change False to True):
Private Sub CommandButton1_Click()
   EnableControls Me.Frame1, False
End Sub

Open in new window

Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011
Commented:
Try

Dim ctrl as control

    For each ctrl in me.frame1.controls
        Ctrl.enabled = not(ctrl.enabled)
    Next

Obviously this toggles to expressly disable simply set to false

Chris

Author

Commented:
Thankz guyz

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial