How to laod a Word document into a richtextbox? RRS feed

  • Question

  • Hi,

    I use an openfiledialog to load differnet textfiles into a richtextbox.

    This works fine fort *.txt or *.rtf files.
    But not for *.doc or *.docx files.

    How can I load word-documents?

    Liebe Gruesse Stefan | Cheers Stefan Iam using VB 2017 Express Be a good forum member - mark posts that contain the answers to your questions or those that are helpful. c# in vb Translator:

    Thursday, September 13, 2018 12:37 PM

All replies

  • You can embed Winword with a WebBrowser (KB304643)

    (with BrowserFlags = 0x80000024 in the registry for Word.Document.n key (n according to version, e.g Word.Document.8 for .doc >= Word 97) to prevent that a new window opens (KB927009)

    (tested on Windows 10 with Office 2016)

    Thursday, September 13, 2018 12:58 PM
  • Hello, 

    No, you can't.

    First of all - there are no specification available for *.doc files format - it's internal for microsoft. So, nobody can create proper loader for *.doc.

    Second - *.txt and *.rtf files didn't contain executable scripts within the file. *.doc - can contain such scripts pluss lot of embedded ActiveX objects - result of the document processing will depend from many side components.

    There is more thinks which prevent loading a *.doc into richtextbox.


    If you need to extract text form *.doc you could look on running Word in automation mode and use it to load the *.doc and after that extract text, possibly in RTF-format, from automation object.

    Best regards,


    Thursday, September 13, 2018 1:45 PM