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 1059553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:11:28+00:00 2026-05-16T18:11:28+00:00

I already added the microsoft reference in. But basically what I want to do

  • 0

I already added the microsoft reference in. But basically what I want to do is read the whole document and go line by line and if the line contains $, split based on $ and do some simple int’s.

For the most part I want to do this while keeping the document in the exact formating it’s in. Or simply put I want to do

string myworddoc = File.ReadAllLines(@"C:\doc.docx");
foreach(string myword in myworddoc)

but how do I do that with a word document?

  • 1 1 Answer
  • 3 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-05-16T18:11:28+00:00Added an answer on May 16, 2026 at 6:11 pm

    I’m a little unclear what it is you’re trying to accomplish here, but manipulating Word documents isn’t terrible. You’ve got two ways to go.

    The first is to use Word interop to manipulate the document. Word interop opens an instance of MS Word and exposes an object model for you to manipulate the document itself. This is a pain, but sometimes it’s what you have to do. Here’s an example:

    ApplicationClass ap = new ApplicationClass();
    Document doc = ap.Documents.Open(@"C:\doc.docx");
    

    From here you can use the doc object to access the Contents property. That’ll give you things like Text and Find.

    Personally, I find the Interop cumbersome. Fortunately, it looks like you’re working with 2007 or higher and your documents are formatted using OpenXML (the .docx extension indicates this). In this case, you can use the Open XML SDK (downloadable from Microsoft) to work with your Word document. This allows you to manipulate things without starting the MS Word process. Here’s an Example (note that I’m using a number of different namespaces here–mainly DocumentFormat.OpenXml.Packaging and DocumentFormat.OpenXml.Wordprocessing).

    WordprocessingDocument doc = WordprocessingDocument.Open(@"C:\doc.docx", false);
    foreach(Text textsection in doc.MainDocumentPart.Document.Descendants<Text>())
    {
        // do something here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which already contains an index in MySQL. I added some
I already sent the bug to fsbugs@microsoft.com but I also added this link to
Already finished implementing the player. I want to implement the progress bar. But I
I have a tracked database (already added) file in git. I want this file
I am creating a sort of Command line in Python. I already added a
I have already added delay loading to my project, using the instructions in http://msdn.microsoft.com/en-us/library/151kt790.aspx
In Australia we have to advertise products with tax already added, so rather than
I added a project, Project2, to my solution. It already had another project lets
Already found this page with some helpful hints. Problem is I need to debug
We already have the database with real data inside. Now we want to build

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.