I am using Visual studio 2005(.NET framework 2.0) .My project is window application and using c# language. We are having word templates created in office 2003, 2007 and 2010.
I want to search text (string) in word template (.dot/.doc/.docx).This text/string is exist in two places in word doc :
1) table
|
Question Title |
Issue no |
Change description |
Page no |
Title |
Modified By |
date |
|
«QUESTION_TITLE» |
«Issue_no» |
xyz |
«QUESTION_MODIFICATION_NAME» |
«QUESTION_MODIFICATION_DATE» |
2) title/subtitle
1.2.1 xyz
I want the page no and title/subtitle to copy into table of word doc.
For an example : table is exist on page 1 and having column value as xyz under column Change description of word doc. Title/Subtitle 1.2.1 is exist on page no 3 with value xyz in word doc.
Now I want to update table by page no and title/subtitle of word doc:
|
Question Title |
Issue no |
Change description |
Page no |
Title |
Modified By |
date |
|
«QUESTION_TITLE» |
«Issue_no» |
«QUESTION_MODIFICATION_DESCRIPT» |
3 |
1.2.1 |
«QUESTION_MODIFICATION_NAME» |
«QUESTION_MODIFICATION_DATE» |
I am not able to find c# code to search text/string(xyz) in word doc and modify table with page no(3) and title(1.2.1) in word doc.
Please help me to find c# code.
Sharon WhitePosted Nov 20, 2012, 1:16 AM
There is code for finding text
TextSelection[] textSelections = document.FindAllString("xyz", true, true);
I use a C# Word component.
About updating, I want to know if you have data source. If so, you can use mail merge function to updating table directly.
About mail merge, this post may be helpful for you.
http://janewdaisy.wordpress.com/2011/04/26/generate-invoice-with-mail-merge-by-using-c/