P
pmm
Hi
I have a problem with a table/texbox object placed in pagefood. Se the
description and code here:
'-------------------------------------------------------------------------
' WANT: Replace existing text with new text - format it - in the
pagefood,
' 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 pagefood, 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
I have a problem with a table/texbox object placed in pagefood. Se the
description and code here:
'-------------------------------------------------------------------------
' WANT: Replace existing text with new text - format it - in the
pagefood,
' 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 pagefood, 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