locked
How can I reference a file into ActiveX object for RichTextBox RRS feed

  • Question

  • So this is a problem for me I am trying to add ActiveX object to the richtextbox which I can do however if I want to reference a word file how can I access the word file before inserting the ActiveX. I read this article on codeproject

    Inserting images into a RichTextBox control (the OLE way)”

    i referenced the richtextbox as such

    richtextbox.InsertActiveX(“Word.Document.12”);

    but it’s its empty no file so I need to use a openfiledialog then select the file and then reference it back to insert Active X to show the file so it’s no empty.

    Monday, September 14, 2020 10:38 PM

All replies

  • E_METHOD_NOT_EXIST, at least not the native RichTextBox or the WPF one anyway.

    The closest I can find on the web are for C++. If you used a wrapper library or somehow extended it yourself, you have to mention it on your question.

    EDIT: Btw, by checking the RTF specification, \objocx has "**" at the side of it, means the relevent control word was introduced in Word 2000 and may not be implemented in the native RichTextBox control.

    EDIT2: It seems that you can also use \objemb and \objsetsize\objw<width>\objh<height> then \objclass control word with class name, and \objdata to specify the embedded OLE2 stream of data (HEX encoded string data from OleSaveToStream() , and you can see example on how to use IPersistStream in C# here ).

    Tuesday, September 15, 2020 1:24 AM
    Answerer
  • Hi Daszbin,

    Thank you for posting here.

    Have you tried using a newer version of the .Net Framework?

    Starting from .Net Framework 4.7, pictures can be displayed directly in the RichTextBox without any additional operations.

    Is this what you want?

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 15, 2020 5:40 AM
  • Use OleCreateFromFile

    (tested on Windows 10)

    Tuesday, September 15, 2020 9:10 AM
  • Funny that the documentation page for all the ole.h functions are still not completed (only parameter types and no parameter names, and parameter descriptions are all TBD).

    Btw, the completed documentation comes from ole2.h.

    Wednesday, September 16, 2020 1:43 AM
    Answerer