Board index » delphi » Reading the formatted text of table of a document to other document's table

Reading the formatted text of table of a document to other document's table

Hi,

I have one document in which I have table and first cell has formatted txt
and I want to read the content of this first cell of the table into other
documents table's first cell.

I have piece of code , please go through whats the wrong and suggest me on
this?

TForm1.Button1Click(Sender : TObject);
var
  Name, LRow, LCol : OleVariant;
  MyRange : Range;
begin
  LRow := 2;
  LCol := 2;
  WordApp.Connect;
  WordApp.Document.Add(Name,EmptyParam); (Name := C:\Table.doc)
  WordDoc.connectTo(WordApp.ActiveDocument);
  WordApp.ActiveDocument.Tables.item(1).cell(1,1).Range.select;
  MyRange := WordApp.Select.FormattedTex;
  WordApp.Document.add(EmptyParam, EmptyParam);// Adding new document to
MSWord

WordApp.ActiveDocument.Tables.Add(WordApp.ActiveDocument.Paragraph.Item(1),
LRow,LCol);-- Table Added to new doc
 WordApp.ActiveDocument.Tables.Item(1).Cell(1,1).Range.FormattedText :=
MYRange
end;

It hangs the application and does not print the content of the cell content
of first table of first document into the other.

Thanks in anticipation

 

Re:Reading the formatted text of table of a document to other document's table


<<Nsplidcngp:
I want to read the content of this first cell of the table
into other documents table's first cell.

Quote

FormattedText doesn't seem to work with table cells. You
can use Copy and Paste, though, to preserve formatting:

  Doc.Tables.Item(1).Cell(1, 1).Range.Copy;
  Word.Documents.Add(EmptyParam, EmptyParam);
  Tbl := Word.ActiveDocument.Tables.Add(
    Word.ActiveDocument.Content, 2, 2);
  Tbl.Cell(1, 1).Range.Paste;

--
Deborah Pate (TeamB) http://delphi-jedi.org

  TeamB don't see posts sent via Google or ISPs
  Use the real Borland server: newsgroups.borland.com
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads