This is the last of the InterOp posts. Just a brief word on the "why", since I keep getting that question :)
I would not recommend InterOp as a first choice for writing a feature, or probably even a second choice. However, there are certain IT shops that have a fear of 3rd party components (they've been burned before, or have NIH syndrome, etc) or a mandate against using OSS. Writing our own spell checker or rich text editor can be very time consuming, so if InterOp is on the table, it's a viable alternative to writing it yourself. However, InterOp can be a deployment headache, unless you know that every user will have Office, and will have the same version. Okay, on with the show.
I was tasked with putting a rich text editor into a WinForms app, to handle the editing of email body templates. I was actually pretty shocked to find that there aren't really any decent open source or free RTEs for WinForms (at least that I could find). I briefly toyed with putting TinyMCE into a webbrowser control, but after reading a few blog posts, I decided to give InterOp a whirl and use the Trident (MSHTML) engine to be a rich text editor.
The idea is basically to use a WebBrowser control, set the 'document' in that control to 'edit mode' and voila, HTML rich text editor. Then you can program buttons to send 'commands' to the document, such as 'bold', 'italic', 'create link', etc. I won't post a code snippet here, because it's a relatively big hunk of code. Instead, I created an open source project called YARTE, or "Yet Another Rich Text Editor". I've tried to make it easy enough to use right out of the box, but extensible enough to add in custom functionality when necessary.

So that wraps it up for InterOp, for now. These InterOp posts were born out of necessity and experience. Not because I'm an InterOp nut or a WinForms fan (because I am neither), but in the hopes that I can help developers in similar situations to the one I was in.


