how to get a table

J

Jed

When I want to get the table in the word ,I used codes like this:

oWordApplic = new Word.ApplicationClass();
oDoc=new Word.Document();
string strContent = "";
Open(strFilePath);
object x="3";
oDoc.ConvertNumbersToText (ref x);
strContent = oDoc.Content .Text ;
return strContent;

But I only can get the content which in the table ,it means "table lost".
How can I get what I want?
Thanks a lot !
 
D

Doug Robbins - Word MVP

You can't put a table into a string.

Not really sure what you are wanting to do, but the following will take a
table from one document and put it into another:

Dim Source As Document, Target As Document, mytable As Table
Set Source = ActiveDocument
Set Target = Documents.Add
Set mytable = Source.Tables(1)
mytable.Range.Copy
Target.Range.Paste


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

Jed

At first,thank you for your answer.
What I want to do is : open the source document and print it,but if the
source document has tables ,when I click "open" to open it ,what I saw is
"table lost",can you tell me what can I do to get I want?

“Doug Robbins - Word MVPâ€ç¼–写:
 
D

Doug Robbins - Word MVP

I gather that you are not opening the document with Word. If you want to
print the contents of the document including the table, you will have to use
Word to do it.

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

Jed

HI,thanks for your attention.
Maybe I have not given the clearly depiction.
I means that:
I have an source document and I have an button named "create formal
file"(CFF),
and another button named"view formal file"(VFF).
What I want to do is :After I give the file's route and click button(CFF),
the source document will save to the specify route,and when I click the button
(VFF),the saved document will opened by myself component.
Now,the question is :if the source document's contents including the
table,when
I click the button(VFF),the document opened by myself component will lost the
table.
Following codes are in my button(CFF):Now,could you tell me ,how can I do to get I want?I don't want to copy the
table between two documents.
Perhaps you know what I said.
Thank you again!

“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