![]() |
#4
|
||||
|
||||
![]()
You might try something like:
Code:
Sub RelocateTextBoxes() Application.ScreenUpdating = False Dim Doc As Document, i As Long, s As Long, v As Long, x As Long, Rng As Range, ArrShp() As String Set Doc = ActiveDocument: ReDim ArrShp(0) With Doc v = .ActiveWindow.View.Type: .ActiveWindow.View.Type = wdOutlineView For s = 1 To .Shapes.Count If Left(.Shapes(s).Name, 2) = "TB" Then i = i + 1: ReDim Preserve ArrShp(i): ArrShp(i) = Format(Split(.Shapes(s).Name, "TB")(1), "000") End If Next WordBasic.SortArray ArrShp() For s = 1 To UBound(ArrShp) i = CLng(ArrShp(s)) With .Shapes("TB" & i) Set Rng = Doc.GoTo(What:=wdGoToPage, Name:=i) If s > 1 Then If Rng.Start < Doc.Shapes("TB" & i - 1).Anchor.End Then Rng.Start = Doc.Shapes("TB" & i - 1).Anchor.End End If x = -(Rng.Start < .Anchor.Start) '1= wdRelocateDown, 0 = wdRelocateUp If Rng.Start < .Anchor.Start Then Rng.End = .Anchor.Start - 1: Rng.Relocate Direction:=x Else Rng.Start = .Anchor.End + 1: Rng.Relocate Direction:=x End If End With Next .ActiveWindow.View.Type = v End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
shapes, word vba |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
move new email to a specific folder | roofi | Outlook | 1 | 10-30-2015 07:20 AM |
![]() |
Byron Polk | Word VBA | 4 | 08-07-2014 03:21 AM |
![]() |
bcarlier | Word Tables | 17 | 05-10-2014 02:36 PM |
How to make word ignore a specific shape when printing? | ZAK | Word | 12 | 04-07-2014 03:14 PM |
![]() |
grumby1 | Word | 6 | 02-18-2014 07:53 PM |