Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-12-2024, 03:05 PM
gmaxey gmaxey is offline Grouped Shapes Not Anchoring to Original Paragraph in Word VBA Windows 10 Grouped Shapes Not Anchoring to Original Paragraph in Word VBA Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
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
  #2  
Old 12-12-2024, 03:55 PM
ADAL ADAL is offline Grouped Shapes Not Anchoring to Original Paragraph in Word VBA Windows 10 Grouped Shapes Not Anchoring to Original Paragraph in Word VBA Office 2021
Novice
Grouped Shapes Not Anchoring to Original Paragraph in Word VBA
 
Join Date: Dec 2023
Posts: 26
ADAL is on a distinguished road
Default

First of all, thanks for the effort, but unfortunately, it doesn't work; it still moves the anchor to the paragraph above, as you can see in the picture:
3.png
I don't sure what you were trying to achieve with:
Code:
shpGroup.Anchor.Start = lngStart
shpGroup.Anchor.End = lngEnd
But the problem is that (according to what I read on the Office documentation) Anchor is a read-only property, so you can't change it.
Maybe macropod could know the answer, but I don't know how to tag him in the forum so he can see this post.
Reply With Quote
Reply

Tags
shapes, vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Grouped Shapes Not Anchoring to Original Paragraph in Word VBA Get rid of auto-numbering, but keep the original paragraph numbers qubie Word 6 05-21-2020 05:09 PM
Outlook increases paragraph spacing when including original in reply Bud Outlook 0 05-13-2016 11:51 PM
Grouped Shapes Not Anchoring to Original Paragraph in Word VBA Exporting Grouped Shapes JamesEddy Word 4 12-08-2014 08:16 AM
Grouped Shapes > "Save Picture As" JamesEddy Word 0 10-29-2014 01:29 PM
Grouped Shapes Not Anchoring to Original Paragraph in Word VBA Anchoring photo to paragraph tharmon Drawing and Graphics 3 06-07-2012 03:43 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft