Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 12-22-2024, 05:00 PM
macropod's Avatar
macropod macropod is offline How can I move an existing shape to a specific page? Windows 10 How can I move an existing shape to a specific page? Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
 

Tags
shapes, word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
move new email to a specific folder roofi Outlook 1 10-30-2015 07:20 AM
How can I move an existing shape to a specific page? Move shape to bookmark location Byron Polk Word VBA 4 08-07-2014 03:21 AM
How can I move an existing shape to a specific page? Move existing table captions 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
How can I move an existing shape to a specific page? How to insert a cover page inbetween each existing page when printing grumby1 Word 6 02-18-2014 07:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:26 AM.


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