none
Create a console application that reads a WORD document using Javascript RRS feed

  • Question

  • Hello, would i be able to create a batch console application that reads a WORD document using Javascript, like i'm currently doing with a C# program?

    Or maybe even use the "Windows Scripting Host" framework to read a WORD document using this framework's own version of Javascript called JScript i think?

    Thanks for any pointers!

    BobK 

    Friday, December 6, 2013 5:17 PM

Answers

  • Hello BobK,

    The *.docx file format (open xml file format) represents a zipped folder with files and folders inside. So, you can rename the file (*.docx ->*.zip) and extract the content. Then you can read files parsing them manually or by using the Open XML SDK (is built on top of the System.IO.Packaging API).

    To read the the *.doc files you need to use the Word Object Model. For example, you can use the following code to get access to the object mode:

    var oApplication=new ActiveXObject("Word.Application");
    oApplication.Documents.Open("myfilename");
    var oDocument=oApplication.ActiveDocument;
    


    Saturday, December 7, 2013 12:28 PM

All replies

  • Hi Bob

    What kind of Word document? The newer kind (docx, etc.) or the old binary format (doc)?


    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, December 7, 2013 11:52 AM
    Moderator
  • Hello BobK,

    The *.docx file format (open xml file format) represents a zipped folder with files and folders inside. So, you can rename the file (*.docx ->*.zip) and extract the content. Then you can read files parsing them manually or by using the Open XML SDK (is built on top of the System.IO.Packaging API).

    To read the the *.doc files you need to use the Word Object Model. For example, you can use the following code to get access to the object mode:

    var oApplication=new ActiveXObject("Word.Application");
    oApplication.Documents.Open("myfilename");
    var oDocument=oApplication.ActiveDocument;
    


    Saturday, December 7, 2013 12:28 PM