> I am creating a website that uses an Access 2000 database and ASP.
> However my client needs certain data to represented as rich text, ie I
> need to be able to store rich text into a plain text database field and
> create a simple user interface to enter the text.
>
> To solve a similar problem for a previous website, after looking at and
> dismissing many other options, I ended up using the following technique:
>
> - Found and customized a custom Visual Basic ActiveX control (not .NET)
> that subclasses the RichEdit control and exposes the tom interface (text
> object model, similar to the the MS Word object model). I called this
> ActiveX control RichEditTom.
>
> - Inserted the RichEditTom control into an Access form, along with
> buttons to make text bold, italic, etc.
>
> - Used the tom interface to handle user interface events, eg clicking on
> the add bulleted list button, undo/redo, etc.
>
> - Saved the rich text in XML form into a plain text field.
>
> The main reason I went to all this trouble was that I needed a way to
> insert hyperlinks into the text. The MS Rich Text control was no good
> for my purposes as you cannot create a link that has a url that is
> different from the visible link text. Indeed most third party controls I
> came across suffered from this problem.
>
> Even though the RichEdit control too has this drawback, the tom objects
> allowed me to handle hyperlinks as I needed by manually formatting text
> to make it look like a link (underlining it in blue) and adding the url
> as hidden text just before the link text. But as you can imagine, this
> led to some very messy code, for example having to take to care when a
> user added text just before the link.
>
> This time around, I am desperately hoping that using the WebBrowser
> control, MSHTML and VBA could provide a much more elegant solution.
> However, in my early experiments I am encountering some potentially
> show-stopping problems that I hope you can help me to solve.
>
> Note that my Access form contains a WebBrowser control which loads a
> simple template HTML document. Then I get a reference to the
> corresponding HTMLDocument object and use it to set the contentEditable
> property of the body tag to true.
>
> So far so good. I can enter text, copy/paste, undo/redo, enter
> hyperlinks (all using the standard keyboard shortcuts), even use Access
> buttons to trigger the HTMLDocument.execCommand to make simple
> formatting changes, eg make text bold. Below though are the issues that
> could render all this useless:
>
> - At the moment the Return key has no effect, ie I cannot enter new
> paragraphs. I have tried using the Access form's KeyPreview property to
> intercept key presses to manually insert paragraphs -
> HTMLDocument.execCommand("InsertParagraph", True). But any text on the
> new line appears outside of the corresponding
tags (eg "
new
> line text").
>
> - When pasting from a Word document etc, a lot of unwanted messy HTML is
> added. I need to be able to modify the clipboard content before it is
> processed by HTMLDocument. How do I do this? I already have code to read
> data from the clipboard, just need to know how to capture the paste key
> combination before the document.
>
> - I need to be able to open a custom link entry form when a user wants
> to enter/edit a hyperlink (to be able to link to other objects in the
> database etc).
>
> Basically, from what I can tell, I really need to able to add Edit
> Designers (and use other MSHMTL interfaces) that appear only to be
> accessible using C++ - need to invoke IHTMLDocument.QueryInterface etc.
> Looking back at the code for RichEditTom, I am guessing though I could
> gain access to these interfaces using a similar technique to the one