1

In my programm code I want to read specific string from my word file and want to create table after that string. I do not have much idea about how can i do that. It will be very helpful if some can help me!!

Till now I know only how to open a word file but dont know how to read specific string value and create table.

Thanks in Advance.

        object oMissing = System.Reflection.Missing.Value;
        object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */

        //Start Word and Open existing Safety device Word file document.
        Word._Application OpenWord;
        Word._Document OpenDoc;
        OpenWord = new Word.Application();
        OpenWord.Visible = true;
        OpenWord.WindowState = Word.WdWindowState.wdWindowStateMaximize;
        OpenDoc = OpenWord.Documents.Open(FilenametextBox.Text, ref oMissing, ref oMissing, ref oMissing);

        Word.Document wordDocument = OpenDoc as Word.Document;
        wordDocument.Activate();

I want to read "Tool change" string from word file. then create some table and fill the table with data

5
  • Possible duplicate of Creating Dynamic Tables in Word by C#.NET Commented Jan 28, 2019 at 10:39
  • where do u wanna create tables ? database ? in memory ? what is the logic for creating tables , like what would be the table name what would be the column name what would be the values etc .. Commented Jan 28, 2019 at 10:41
  • I want to crate table in the same word file and table name would be the same as what we read in the string value. and table should have 5 rows and 5 coloums and first row should be same for all the table like for eg. firsz row should be...Comment, Device name, Module name, Element name, circuit name. Commented Jan 28, 2019 at 10:45
  • Based on what I can find online the bit that's going to cause you problems here is going to the "Tool change" text. To navigate around the document you'll need to use one of these types of object: learn.microsoft.com/en-us/dotnet/api/…. From here, Heading looks like your best bet if you can ensure "Tool Change" is a heading, otherwise maybe you can add a bookmark? Once you find the range with GoTo then you can use InsertAfter to add your table in the appropriate location. Commented Jan 29, 2019 at 1:32
  • Also, perhaps look into OpenXML for Word, which might give you an easier way of doing things than the Interop libraries. Commented Jan 29, 2019 at 1:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.