Problem with table text with formatting

S

Sol Apache

I have this code:

Dim myRg As Range
Set myRg = _
ActiveDocument.Tables(1).Cell(Row:=4, Column:=2).Range

With myRg
.Text = TxtMainName.Value & Chr(13)
.Style = ("NameSurname")
.Collapse wdCollapseEnd
.Text = TxtDivision.Value & Chr(13)
.Style = ("DivisionalName")
.Collapse wdCollapseEnd
.Text = TxtJobTitle.Value
.Style = ("JobTitle")
..Collapse wdCollapseEnd
End With

For some reason the first line goes into row 4, column 2,
But the remaining two rows go into row 4 column 3.

Have checked other rows in the table, and I get the same result: line 1 goes
into designated column, lines 2 & 3 go into next column.

What is wrong?
 
D

Doug Robbins - Word MVP

instead of

..Collapse wdCollapseEnd

use

..Start = .End

--
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
 
S

Sol Apache

Thanks I tried this. While I waited for your reply I found that if I
inserted .delete in a line just after With myRg then everything went into
the right cell. Don't know why.

Have checked out your suggestion and it works too.
 

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