1

I have to convert an Access VBA app over to VB.NET and one of the text boxes (format set to RichText) on the VBA app accepts a straight paste from a Word document including its formatting and saves it to the Access database as HTML... The HTML is then read from the database and displayed as it was originally pasted when retrieved. The issue I have now is, I can use a web browser control to display the data properly from the database, but the RichTextBox gives an Invalid File Format error. When I wish to edit the data I switch the web browser control to the back and copy the data and paste it into the RichTextBox control and then bring the RichTextBox control to the front. This works fine, but once an update is attempted, the data gets saved in RTF format which is not HTML and then when I try to bring it up again from the database, the browser doesn't interpret it as it is not HTML. How can I save it from the RichTextBox, to HTML into the database like the VBA app can?

Shane LeBlanc
  • 2,633
  • 13
  • 42
  • 74

1 Answers1

1

I've used this in C#:

Create a WebBrowser. Copy and paste the contents from your richtextbox to the webbrowser. And then read the html content (DocumentText) property from the webbrowser.

Edit: Another way: Use Office Interop, create a Word file, copy and paste into this file and then save as html.

Jerry
  • 4,258
  • 3
  • 31
  • 58
  • I'll definitely try this tonight or tomorrow. – Shane LeBlanc May 06 '13 at 19:38
  • How do I paste into the webbrowser control? Doesn't seem to want to paste. I've used webbrowser.Document.ExecCommand("Paste", False, Nothing) and it doesn't paste the contents. – Shane LeBlanc May 07 '13 at 12:15
  • use webbrowser.Navigate("about:blank"); before pasting – Jerry May 07 '13 at 14:15
  • Still doesn't paste. My richtextbox is txtMiscUpdates so I type txtMiscUpdates.SelectAll() > txtMiscUpdates.Copy() > webMiscUpdates.Navigate("about:blank") > webMiscUpdates.Document.ExecCommand("paste", False, Nothing) – Shane LeBlanc May 07 '13 at 14:26