Forum Discussion

DanMcG's avatar
DanMcG
Brass Contributor
May 04, 2021
Solved

how to nudge a control located in a parent object (like a frame)

I created a nudge command that moves the top/left properties of selected controls of a userform in a particular direction. now that I am using it, I see an issue with the command. Any parent controls...
  • DanMcG's avatar
    DanMcG
    May 05, 2021

    DanMcG 

    For Each ctl In Workbooks(activeWb).VBProject.VBComponents(preserveName).Designer.Selected
        If TypeName(ctl) = "Frame" Then
            For Each ctl2 In               Workbooks(activeWb).VBProject.VBComponents(preserveName).Designer.Controls(ctl.Name).Selected
                childCount = childCount + 1
                ctl2.Left = ctl2.Left + (lngDistanceInPixels / 2)
            Next ctl2
            If childCount = 0 Then ctl.Left = ctl.Left + (lngDistanceInPixels / 2)
            childCount = 0
        ElseIf TypeName(ctl) = "MultiPage" Then
            pageSelect = Workbooks(activeWb).VBProject.VBComponents(preserveName).Designer.Controls(ctl.Name).Value
                For Each ctl2 In       Workbooks(activeWb).VBProject.VBComponents(preserveName).Designer.Controls(ctl.Name).Pages(pageSelect).Selected
                    childCount = childCount + 1
                    ctl2.Left = ctl2.Left + (lngDistanceInPixels / 2)
                Next ctl2
                If childCount = 0 Then ctl.Left = ctl.Left + (lngDistanceInPixels / 2)
                childCount = 0
            ElseIf TypeName(ctl) = "TabStrip" Then
                ctl.Left = ctl.Left + (lngDistanceInPixels / 2)
            Else
                ctl.Left = ctl.Left + (lngDistanceInPixels / 2)
            End If
        Next ctl

Resources