Linking Text Boxes

M

MRupel

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
 
D

Doug Robbins - Word MVP

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.
 
M

MRupel

Hello Doug,

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

MRupel

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....
 
D

Doug Robbins - Word MVP

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
 
M

MRupel

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!
 
D

Doug Robbins - Word MVP

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
 
D

Doug Robbins - Word MVP

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.
 
M

MRupel

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!
 
M

MRupel

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
 
M

MRupel

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.
 
D

Doug Robbins - Word MVP

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.
 
M

MRupel

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?
 
D

Doug Robbins - Word MVP

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.
 
M

MRupel

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
 
D

Doug Robbins - Word MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top