none
I am facing below error so please give the solution and i want to read the text content from word document RRS feed

  • Question

  • Error 1 'Microsoft.Office.Interop.Word.ApplicationClass' does not contain a definition for 'Documents' and no extension method 'Documents' accepting a first argument of type 'Microsoft.Office.Interop.Word.ApplicationClass' could be found (are you missing a using directive or an assembly reference?)
    • Moved by Fred Bao Wednesday, February 18, 2015 5:23 AM Office Related
    Tuesday, February 17, 2015 3:31 PM

Answers

  • Hi,

    Did the suggestion provied by Ammar.Zaied fix this issue?

    If not, would you mind sharing the code you are developing with? Also here are a samlpe that open existing document and get the content in it for your reference:

     string fileName = @"C:\Users\UserName\Desktop\doc1.docx";
                Word.Application word = new Word.Application();
                Word.Document doc=word.Documents.Open(fileName);
     
                Console.WriteLine(doc.Content.Text);
                
                doc.Save();
                word.Quit();

    And to run this code, we need to add the Microsoft.Office.Interop.Word for reference and the name space like code below:

    using Word = Microsoft.Office.Interop.Word;

    Also here are some helpful article about learning Word automation:
    How to automate Microsoft Word to create a new document by using Visual C#

    Welcome to the Word 2013 developer reference

    Welcome to the Word 2013 Primary Interop Assembly Reference

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 18, 2015 6:05 AM
    Moderator

All replies

  • Hi,

    to resolve this try to change:>

    namespace 

    Microsoft.Office.Interop.Word.

    UPDATE

    Use Word.Application


    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

    Tuesday, February 17, 2015 3:57 PM
  • Hello,

    Since this issue is related with office development, i move it to the office forum.

    The current forum you posted to is used to discuss and ask questions about the C# programming language, IDE, libraries, samples, and tools.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 18, 2015 5:21 AM
  • Hi,

    Did the suggestion provied by Ammar.Zaied fix this issue?

    If not, would you mind sharing the code you are developing with? Also here are a samlpe that open existing document and get the content in it for your reference:

     string fileName = @"C:\Users\UserName\Desktop\doc1.docx";
                Word.Application word = new Word.Application();
                Word.Document doc=word.Documents.Open(fileName);
     
                Console.WriteLine(doc.Content.Text);
                
                doc.Save();
                word.Quit();

    And to run this code, we need to add the Microsoft.Office.Interop.Word for reference and the name space like code below:

    using Word = Microsoft.Office.Interop.Word;

    Also here are some helpful article about learning Word automation:
    How to automate Microsoft Word to create a new document by using Visual C#

    Welcome to the Word 2013 developer reference

    Welcome to the Word 2013 Primary Interop Assembly Reference

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 18, 2015 6:05 AM
    Moderator