selecting and pasting rich text

  • Thread starter Ted Theodoropoulos
  • Start date
T

Ted Theodoropoulos

i am trying to select the contents of a cell in a Word 2K table and
copy and paste the contents elsewhere in the document. the problem is
that the formatting is lost. the .FormattedText property doesn't seem
to help in the least. i've been tinkering with various
methods/properties for almost a whole day. any suggestions?
please?!?!


Public Sub Test()

Dim objDoc As Word.Document
Dim oSel As Word.Selection
Dim rng As Range

Set objDoc = Application.ActiveDocument
objDoc.Tables.Item(1).Cell(3, 2).Range.Select

'oSel = objDoc.Tables.Item(1).Cell(3, 2).Range.
objDoc.Tables.Item(1).Cell(4, 2).Range.Text = Selection.Text

'Set rng = objDoc.Tables.Item(1).Cell(3, 2).Range
'objDoc.Tables.Item(1).Cell(4, 2).Range.InsertAfter (rng.Text)

End Sub
 
D

Doug Robbins - Word MVP

Hi Ted,

Use

Dim myrange As Range
Set myrange = ActiveDocument.Tables(1).Cell(3, 2).Range.FormattedText
myrange.End = myrange.End - 1
ActiveDocument.Tables(1).Cell(4, 2).Range.FormattedText = myrange


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
T

Ted Theodoropoulos

thanks doug. that was very helpful. what is the following line of
code necessary? TIA!

myrange.End = myrange.End - 1
 
D

Doug Robbins - Word MVP

Hi Ted,

That is required to eliminate the end of cell marker from the range. If you
don't do that you will get a cell inserted inside the cell (that is a single
cell nested table)

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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