O
Ogier
The code snippet below works as intended: It inserts in the main document
some text in bold with different font sizes:
Dim rng As Word.Range
Set rng = Selection.Range
With rng
.Text = "Table "
.Font.Bold = True
.Collapse wdCollapseEnd
.InsertAfter " " & "Title"
.Font.Grow
.Collapse wdCollapseEnd
.InsertAfter Chr(11) & "Subtitle"
.Font.Shrink
.Font.Shrink
.Collapse wdCollapseEnd
.Font.Grow
.Font.Grow
.Font.Bold = False
End With
However, if I use it in a table,
Set rngCell = tbl.Rows(1).Range
I get "RTE 5251 This action is illegal at the end of a row"
The row consists of a single cell (created by merging other cells.
If I try to insert in a cell which is not the last one in its row, using
Set rngCell = tbl.Cell(4, 1).Range
the text 'Table' is written in this cell, but the rest of the text spills over
into cell (4,2).
I have also tried to do the merging of the cells in the first row *after*
inserting the text. But in this case an unwanted like break appears after
'Table'.
So how do I insert differntly formattet text into a single cell of a table?
Best regards
Holger Nielsen
some text in bold with different font sizes:
Dim rng As Word.Range
Set rng = Selection.Range
With rng
.Text = "Table "
.Font.Bold = True
.Collapse wdCollapseEnd
.InsertAfter " " & "Title"
.Font.Grow
.Collapse wdCollapseEnd
.InsertAfter Chr(11) & "Subtitle"
.Font.Shrink
.Font.Shrink
.Collapse wdCollapseEnd
.Font.Grow
.Font.Grow
.Font.Bold = False
End With
However, if I use it in a table,
Set rngCell = tbl.Rows(1).Range
I get "RTE 5251 This action is illegal at the end of a row"
The row consists of a single cell (created by merging other cells.
If I try to insert in a cell which is not the last one in its row, using
Set rngCell = tbl.Cell(4, 1).Range
the text 'Table' is written in this cell, but the rest of the text spills over
into cell (4,2).
I have also tried to do the merging of the cells in the first row *after*
inserting the text. But in this case an unwanted like break appears after
'Table'.
So how do I insert differntly formattet text into a single cell of a table?
Best regards
Holger Nielsen