I have a problem with a table/texbox object placed in pagefooter. Se
the
description and code here:
'-------------------------------------------------------------------------
' WANT: Replace existing text with new text - format it - in the
pagefooter,
' and the text shall be place in a table there is place in a
textbox
' (there are already added a textbox and inside this a table:
' one row and one coloum).
' COMMENT:
' It works fine when the texbox and table are placed on the
page
' PROBLEM:
' It can't find the shape in pagefooter, and I don't know how
to
get it.
' (it shall be a shape and not at frame)
'-------------------------------------------------------------------------
Sub ReplaceText_TableTextbox()
Dim txt_adress As Range
With ActiveDocument
Set txt_adress = .Shapes(1).TextFrame.TextRange
txt_adress.Tables(1).Cell(1, 1).Range.Delete
txt_adress.Tables(1).Cell(1, 1).Range = "This is the first line"
txt_adress.Tables(1).Cell(1, 1).Range.InsertParagraphAfter
txt_adress.Tables(1).Cell(1, 1).Range.InsertAfter "This is the
second line"
txt_adress.Tables(1).Cell(1, 1).Range.InsertParagraphAfter
txt_adress.Tables(1).Cell(1, 1).Range.InsertAfter "This is the
last
line"
'Line 1: Bold and spaceafter 10
txt_adress.Paragraphs(1).Range.Bold = True
txt_adress.Paragraphs(1).Range.ParagraphFormat.SpaceAfter = 10
'Line 2: Font size 16
txt_adress.Paragraphs(2).Range.Font.Size = 16
End With
End Sub
Hi again - I'm the author, and I have found a solution you can see
here:
Sub ReplaceText_TableTextbox()
Dim txt As Range
With ActiveDocument
Set txt = .Sections(1).Footers(wdHeaderFooterPrimary) _
.Shapes(1).TextFrame.TextRange _
.Tables(1).Cell(1, 1).Range
txt = "This is the first line"
txt.InsertParagraphAfter
txt.InsertAfter "This is the second line"
txt.InsertParagraphAfter
txt.InsertAfter "This is the last line"
End With
'Line 1: Bold and spaceafter 10
txt.Paragraphs(1).Range.Bold = True
txt.Paragraphs(1).Range.ParagraphFormat.SpaceAfter = 10
'Line 2: Font size 16
txt.Paragraphs(2).Range.Font.Size = 16
End Sub