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

  • Home
  • SEARCH
  • 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
  • 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-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

Parser Error Message: The entry 'SiteSqlServer' has already been added. Source Error: Line 23:
I already know Java, Objective C, C#, and some Python. I want to be
I am working on a Visual Studio 2008 project that is already added to
What is the added value for learning F# when you are already familiar with
Already implemented performance boosters : - Get compatible image of GraphicsConfiguration to draw on
I already know how to: Load properties files into my Spring configuration using: <context:property-placeholder
I already know the obvious answer to this question: just download <insert favorite windows
As already discussed in Lua as a general-purpose scripting language? Lua currently probably isn't
I already have a deploy.rb that can deploy my app on my production server.
We already have things like static analysis that tells us what's wrong with our

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.