Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-22-2024, 12:00 PM
ADAL ADAL 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 2021
Novice
How can I move an existing shape to a specific page?
 
Join Date: Dec 2023
Posts: 26
ADAL is on a distinguished road
Default How can I move an existing shape to a specific page?

Subject: How to Move an Existing Linked Textbox (Shape) to a Specific Page Without Breaking Links?

Hi everyone,

I have a Word document with multiple linked textboxes (Shapes) that are connected to each other. I would like to create a macro to place:

The textbox named TB1 on page 1,
The textbox named TB2 on page 2,
And so on.
The problem is that I cannot create a new textbox in the desired range because doing so breaks the link between the existing textboxes.


My main question is: How can I move an existing shape (textbox) to a specific page without creating a new one?
And to save time for the respondents, I would like to mention, a common mistake, that propety anchor is read only, so i can't do something like:
shp.anchor = rangeX
Any help or guidance would be greatly appreciated!

Thank you!
Reply With Quote
  #2  
Old 12-22-2024, 12:34 PM
Logit Logit 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 2007
Expert
 
Join Date: Jan 2017
Posts: 587
Logit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the roughLogit is a jewel in the rough
Default

Steps:
Select the Linked Textbox:

Click on the edge of the textbox (shape) to select it.
Cut the Textbox:

Press Ctrl + X to cut the textbox.
Navigate to the Target Page:

Scroll to the desired page in your worksheet.
Paste the Textbox:

Press Ctrl + V to paste the textbox in the desired location.
Drag it to adjust its position on the page as needed.
Verify Links Are Intact:

The link should remain functional because cutting and pasting within the same workbook doesn’t break links.
Check Page Layout (Optional):

If you're working in Page Layout View, ensure the textbox appears correctly by toggling between views:
View tab → Select Page Layout.
Reply With Quote
  #3  
Old 12-22-2024, 12:50 PM
ADAL ADAL 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 2021
Novice
How can I move an existing shape to a specific page?
 
Join Date: Dec 2023
Posts: 26
ADAL is on a distinguished road
Default

Hello, thanks for the answer but there are 2 problems here:
1. I need to make a macro, not manually (it's a file with hundreds of pages, and text boxes).
2. As I wrote, cutting breaks the link (this is not a hypothesis, I checked it)
Reply With Quote
  #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,369
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
Reply

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 05:31 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