View Single Post
 
Old 12-12-2024, 03:05 PM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Does this work?


Code:
Sub MACRO5()
Dim lngStart As Long, lngEnd As Long

    Dim shpGroup, C, L, R As Shape
    signon = Selection.Paragraphs(1).Style

    For Each para In ActiveDocument.Paragraphs
        para.Range.Select
        If para.Range.ShapeRange.Count > 0 Then
            If para.Style = signon And para.Range.ShapeRange(1).Name = "A" Then
                Set MYRANGE = para.Range
                MYRANGE.Select
                Selection.HomeKey
                PRINCIPIO = Selection.Information(wdHorizontalPositionRelativeToTextBoundary)
                Selection.EndKey
                FIN = Selection.Information(wdHorizontalPositionRelativeToTextBoundary)
                TAMANO = PRINCIPIO - FIN
                para.Range.ShapeRange(1).Select
                Set shpGroup = Selection.ShapeRange
                lngStart = shpGroup.Anchor.Start
                lngEnd = shpGroup.Anchor.End
                On Error GoTo iGroup
                shpGroup.Ungroup

                For Each shp In shpGroup
                    If shp.Name = "1" Then Set L = shp
                    If shp.Name = "2" Then Set C = shp
                    If shp.Name = "3" Then Set R = shp
                Next

                C.LockAspectRatio = msoFalse
                C.Width = TAMANO
                C.Left = C.Left - ADDITION_IN_EACH_SIDE
                L.Left = C.Left - L.Width
                R.Left = C.Left + C.Width

iGroup:
                shpGroup.Group
                shpGroup.Left = wdShapeCenter
                shpGroup.Anchor.Start = lngStart
                shpGroup.Anchor.End = lngEnd
            End If
        End If
    Next
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote