Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:32:19+00:00 2026-06-09T20:32:19+00:00

I am reading word document in C# (3.5) using Microsoft.Office.Interop.Word . Reading line by

  • 0

I am reading word document in C# (3.5) using Microsoft.Office.Interop.Word. Reading line by line, splitting line into array[] and processing every word of line and based on some business logic replacing some words and after the replacement of words, replacing the complete line with converted line.

Till now Every thing is working fine.

Now i have some word documents, those are having paragraph and tables. I want to read every Column of the table one by one and replace the content of the column in particular column.

Update


Using Office Automation

1. Opening word file.
2. Moving cursor to top of the document
3. Selecting first line using (`wordApp.Selection.endKey`) and processing all words
4. After processing the words replacing the selected line with the processed line.
5. Using wordApp.Selection.MoveDown(ref lineCount, ref countPage, ref MISSING);    
   moving next line processed further.

Problem:
1. When reading table it reads only first column when using wordApp.Selection.endKey

I want to process all column’s data.
Is there any way to identify whether content is paragraph or table?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:32:20+00:00Added an answer on June 9, 2026 at 8:32 pm

    I found a workaround for the same.
    Approach is listed below.

    1. Open the Word Document using WordApp.Documents.Open()
    2. Using Selection.MoveDown to traverse the Document line by line
    3. Skipping the content of the Table’s Cells
    4. At last processing only Tables of the document

    //Process all Paragraphs in the documents
    while (doc.ActiveWindow.Selection.Bookmarks.Exists(@"\EndOfDoc") == false)
    {
      doc.ActiveWindow.Selection.MoveDown(ref wdLine, ref wdCountOne, ref wdMove);
      doc.ActiveWindow.Selection.HomeKey(ref wdLine, ref wdMove);
    
      //Skiping table content
      if (doc.ActiveWindow.Selection.get_Information(WdInformation.wdEndOfRangeColumnNumber).ToString() != "-1")
      {
        while (doc.ActiveWindow.Selection.get_Information(WdInformation.wdEndOfRangeColumnNumber).ToString() != "-1")
        {
          if (doc.ActiveWindow.Selection.Bookmarks.Exists(@"\EndOfDoc"))
            break;
    
          doc.ActiveWindow.Selection.MoveDown(ref wdLine, ref wdCountOne, ref wdMove);
          doc.ActiveWindow.Selection.HomeKey(ref wdLine, ref wdMove);
        }
        doc.ActiveWindow.Selection.HomeKey(ref wdLine, ref wdMove);
      }
    
      doc.ActiveWindow.Selection.EndKey(ref wdLine, ref wdExtend);
      currLine = doc.ActiveWindow.Selection.Text;
    }
    
    //Processing all tables in the documents
    for (int iCounter = 1; iCounter <= doc.Tables.Count; iCounter++)
    {
      foreach (Row aRow in doc.Tables[iCounter].Rows)
      {
        foreach (Cell aCell in aRow.Cells)
        {
          currLine = aCell.Range.Text;
          //Process Line
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there a simple way of reading a microsoft word document in java without
Hi there I'm reading a string and breaking each word and sorting it into
I am trying to replace strings in a word document by reading the file
I am using C# and Microsoft Word 12.0 object library to read data from
I am trying to add bookmarks in word document using C# but it doesn't
When reading text from word files, I get the following output. Some weird characters
Possible Duplicate: Reading/Writing MS Word files in Python I know there are some libraries
I'm reading from a MS Office Word 2010 file (.docx) and then messing with
Reading manual about Sling http://sling.apache.org/site/46-line-blog.html added folder blog and blog.html to destination: \launchpad\content\src\main\resources\content\ but
Reading some questions here on SO about conversion operators and constructors got me thinking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.