Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linking Text Boxes

7 views
Skip to first unread message

MRupel

unread,
Jan 7, 2010, 5:11:02 PM1/7/10
to

Hello!

I am still trying to create a document that has 3 separate text boxes. The
one giving me problems is the one that needs to handle text overflow (if
any). I have the 3 text boxes on page 1. I need for an unlimited amount of
pages to be created (if needed) with these text boxes if there is overflow.
Also I need these text boxes to be stationary and not be deleted or moved
when I press delete on page 1 or page 2, etc. And for text to flow into the
new text box on a new page if there is overflow from the previous page.

Thank you in advance,
Marsha

Doug Robbins - Word MVP

unread,
Jan 7, 2010, 5:19:25 PM1/7/10
to
What about the method that I gave you on December 24?

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"MRupel" <MRu...@discussions.microsoft.com> wrote in message
news:D30A3DC9-E40E-4ACE...@microsoft.com...

MRupel

unread,
Jan 7, 2010, 5:43:02 PM1/7/10
to
Hello Doug,

I'm starting from scratch because I have not been able to get anything to
work properly.

MRupel

unread,
Jan 7, 2010, 6:43:01 PM1/7/10
to

Here is what I have so far:


Sub NewBlankPage()
'
' NewBlankPage Macro
'
'
Dim rng As Range
Set rng = ActiveDocument.Range
rng.Collapse wdCollapseEnd
rng.InsertBreak Type:=wdPageBreak
Selection.GoTo What:=wdGoToPage, Which:=wdGoToLast
Call CreateTextBoxes
Call LinkTextBoxes
End Sub

Sub CreateTextBoxes()
'
' CreateTextBoxes Macro
'
'
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 72#, _
36#, 486#, 18#).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.ShapeRange.Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.25
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(192, 192, 192)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 18#
Selection.ShapeRange.Width = 490#
Selection.ShapeRange.TextFrame.MarginLeft = 7.2
Selection.ShapeRange.TextFrame.MarginRight = 7.2
Selection.ShapeRange.TextFrame.MarginTop = 3.6
Selection.ShapeRange.TextFrame.MarginBottom = 3.6
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
Selection.ShapeRange.Left = wdShapeCenter
Selection.ShapeRange.Top = InchesToPoints(0.5)
Selection.ShapeRange.LockAnchor = True
Selection.ShapeRange.WrapFormat.AllowOverlap = False
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 5
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 63#, _
63#, 490#, 415#).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.ShapeRange.Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.25
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(192, 192, 192)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 415#
Selection.ShapeRange.Width = 490#
Selection.ShapeRange.TextFrame.MarginLeft = 7.2
Selection.ShapeRange.TextFrame.MarginRight = 7.2
Selection.ShapeRange.TextFrame.MarginTop = 3.6
Selection.ShapeRange.TextFrame.MarginBottom = 3.6
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
Selection.ShapeRange.Left = wdShapeCenter
Selection.ShapeRange.Top = InchesToPoints(0.85)
Selection.ShapeRange.LockAnchor = True
Selection.ShapeRange.WrapFormat.AllowOverlap = False
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 5
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 54#, _
540#, 490#, 255#).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.ShapeRange.Select
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.25
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.RGB = RGB(192, 192, 192)
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 255#
Selection.ShapeRange.Width = 490#
Selection.ShapeRange.TextFrame.MarginLeft = 7.2
Selection.ShapeRange.TextFrame.MarginRight = 7.2
Selection.ShapeRange.TextFrame.MarginTop = 3.6
Selection.ShapeRange.TextFrame.MarginBottom = 3.6
Selection.ShapeRange.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
Selection.ShapeRange.RelativeVerticalPosition = _
wdRelativeVerticalPositionPage
Selection.ShapeRange.Left = wdShapeCenter
Selection.ShapeRange.Top = InchesToPoints(6.7)
Selection.ShapeRange.LockAnchor = True
Selection.ShapeRange.WrapFormat.AllowOverlap = False
Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
Selection.ShapeRange.WrapFormat.Type = 3
Selection.ShapeRange.ZOrder 5
End Sub

Sub LinkTextBoxes()
'
' LinkTextBoxes Macro
' Links "Main Content" text boxes
'
With ActiveDocument
With .Shapes(2).TextFrame
If .Overflowing = True Then
Selection.ShapeRange.TextFrame.Next = ActiveDocument.Shapes(2).TextFrame
End If
End With
End With
End Sub

Hope this helps....

Doug Robbins - Word MVP

unread,
Jan 8, 2010, 5:55:14 AM1/8/10
to
To try and get a better understanding of what you want to do let's use the
following nomenclature

p#tb#

so that on page one

you have

p1tb1 - the first textbox

p1tb2 - the second textbox

and

p1tb3 - the third text box

Are there any linkages between any of them?

Then you want to add a page that will have

p2tb1 - the first textbox

p2tb2 - the second textbox

and

p2tb3 - the third text box

Now, what textboxes to to be linked to what using terminology such as

p1tb3>p2tb3

to indicate that the third text box on the first page is to overflow to the
third text box on the second page and so on.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"MRupel" <MRu...@discussions.microsoft.com> wrote in message

news:3D11EE62-D53A-4918...@microsoft.com...

MRupel

unread,
Jan 8, 2010, 11:49:01 AM1/8/10
to
How do I name the TextBoxes 1,2,3??

Does any of the following apply?


> > Sub LinkTextBoxes()
> > '
> > ' LinkTextBoxes Macro
> > ' Links "TextBox2" text boxes

MRupel

unread,
Jan 8, 2010, 12:55:01 PM1/8/10
to

Doug,

All of your nomenclatures are good. I need p1tb2 to flow to p2tb2 if there
is overflow and if needed p3tb2, etc. I need to code for the linkage between
all tb2 only. All of the textboxes on page one are good (I can't delete them
or move them, which is what I want). The newly created textboxes, say on
page 2, are being deleted if I am on page one and I press delete. I need for
them to stay in place on all pages. Seems Anchor = True but....please help.

Thank you!

Doug Robbins - Word MVP

unread,
Jan 9, 2010, 9:09:45 PM1/9/10
to
Set up another document that already contains the three textboxes as I had
previously suggested and use the following code it insert that document at
the end of the present document

Dim rng As Range
Dim i As Long
Dim a As Shape, b As Shape
With ActiveDocument
Set rng = .Range
With rng
.Collapse wdCollapseEnd
.InsertFile "C:\Users\Doug\Documents\NewTextBoxDoc.doc" 'See Note
End With
i = .Range.ShapeRange.Count
Set a = .Range.ShapeRange(i - 4)
Set b = .Range.ShapeRange(i - 1)
a.TextFrame.Next = b.TextFrame
End With

Replace "C:\Users\Doug\Documents\NewTextBoxDoc.doc" with the path and
filename of the document that contains the new textboxes.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"MRupel" <MRu...@discussions.microsoft.com> wrote in message

news:3CEEF482-BD7B-4374...@microsoft.com...

MRupel

unread,
Jan 11, 2010, 5:31:01 PM1/11/10
to

Thank you I will try that...will it also properly auto-number the new pages?

Doug Robbins - Word MVP

unread,
Jan 11, 2010, 6:48:45 PM1/11/10
to
Yes, If page numbering is set up in the header/footer of the document.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"MRupel" <MRu...@discussions.microsoft.com> wrote in message

news:14357E0F-7446-4E12...@microsoft.com...

MRupel

unread,
Jan 11, 2010, 7:34:03 PM1/11/10
to

Good to know. Sorry for all the problems.

Thank you so much!!

MRupel

unread,
Jan 11, 2010, 7:51:02 PM1/11/10
to
Thank you again!!

MRupel

unread,
Jan 11, 2010, 8:01:02 PM1/11/10
to

FYI - This is putting the text boxes on page one overlapping the already
existing text boxes - not at the end of the document or creating a new page.
Darn!

MRupel

unread,
Jan 11, 2010, 8:12:01 PM1/11/10
to

I figured out how to add a blank page and insert the text boxes but still
don't have the text box2 link to text box2. Any thoughts?

Here is what I have:

Dim rng As Range
Dim i As Long
Dim a As Shape, b As Shape
With ActiveDocument
Set rng = .Range
With rng
.Collapse wdCollapseEnd

rng.InsertBreak Type:=wdPageBreak
Selection.GoTo What:=wdGoToPage, Which:=wdGoToLast

.InsertFile "C:\Documents and
Settings\Me\Desktop\Salesperson_Outline\Salesperson_Outline2.dotm"


End With
i = .Range.ShapeRange.Count
Set a = .Range.ShapeRange(i - 4)
Set b = .Range.ShapeRange(i - 1)
a.TextFrame.Next = b.TextFrame
End With

End Sub

MRupel

unread,
Jan 11, 2010, 9:04:02 PM1/11/10
to
OK..forget the overlapping. I got that taken care of. However, your code
linked the first text box and it should link only the second.

Doug Robbins - Word MVP

unread,
Jan 11, 2010, 10:31:42 PM1/11/10
to
If you have 3 text boxes in the original document and 3 in the document that
is inserted then you will have a total of 6 text boxes and the code links
text boxes and

i = .Range.ShapeRange.Count

will set i = 6

The text boxes that are linked a i - 1 and i - 4

6 - 1 = 5

and

6 - 4 = 2

Therefore the second and the fifth textboxes are linked and that is exactly
what happens when I run the code.
--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"MRupel" <MRu...@discussions.microsoft.com> wrote in message

news:A2889876-108B-4951...@microsoft.com...

MRupel

unread,
Jan 12, 2010, 12:28:02 PM1/12/10
to
Doug!! Oh my....I LOVE you!! It is working now!!

Just one more thing (if I may)....the text boxes on the new pages are not
staying on their respective pages even though LockAnchor = True. If I am on
page one and press delete the text boxes from the other pages are being moved
and overlapping onto page one and the other pages are being deleted. Any
thoughts?

Doug Robbins - Word MVP

unread,
Jan 13, 2010, 1:35:07 AM1/13/10
to
Use:

Dim rng As Range
Dim i As Long
Dim a As Shape, b As Shape
With ActiveDocument
Set rng = .Range
With rng
.Collapse wdCollapseEnd

.InsertBreak Type:=wdSectionBreakNextPage
End With


Set rng = .Range
With rng
.Collapse wdCollapseEnd

.InsertFile "C:\Users\doug.robbins\Documents\Continuation Sheet.doc"
'modify path filename as required.


End With
i = .Range.ShapeRange.Count
Set a = .Range.ShapeRange(i - 4)
Set b = .Range.ShapeRange(i - 1)
a.TextFrame.Next = b.TextFrame
End With


--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.

"MRupel" <MRu...@discussions.microsoft.com> wrote in message

news:AA17D828-3FC1-4DC3...@microsoft.com...

MRupel

unread,
Jan 15, 2010, 3:41:01 PM1/15/10
to
Hi Doug,

I tried that new code...but it didn't seem to work. The text boxes are
still being moved to page one and subsequent pages are being deleted.

Marsha

Doug Robbins - Word MVP

unread,
Jan 15, 2010, 6:41:09 PM1/15/10
to
You are probably deleting the Section break as well. Click on the Show/Hide
button (¶) so that you can see what you are doing.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"MRupel" <MRu...@discussions.microsoft.com> wrote in message
news:A034779D-D4D4-40A4...@microsoft.com...

0 new messages