Forum Discussion
how to nudge a control located in a parent object (like a frame)
- May 05, 2021
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
got this to work with Frames but not the multipage by doing the following:
For Each ctl In Workbooks(activeWb).VBProject.VBComponents(preserveName).Designer.Selected
Debug.Print Left(ctl.Name, 9)
If Left(ctl.Name, 5) = "Frame" Or _
Left(ctl.Name, 3) = "frm" Then
For Each ctl2 In Workbooks(activeWb).VBProject.VBComponents(preserveName).Designer.Controls(ctl.Name).Selected
parentCount = parentCount + 1
'Debug.Print ctl2.Name
If parentCount > 0 Then
ctl2.Left = ctl2.Left + (lngDistanceInPixels / 2)
End If
Next ctl2
ElseIf Left(ctl.Name, 9) = "Multipage" Or _
Left(ctl.Name, 3) = "mpg" Then
'do nothing yet as need to find out how to move the child
End If
If parentCount = 0 Then ctl.Left = ctl.Left + (lngDistanceInPixels / 2)
Next ctl
since the multipage acts differently than a frame, how can i make it nudge?
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