Visual Basic find and replace from Access table to Word document

I need to take text from a Rich Text field in Access and paste it into Word using Visual Basic (VBA). I have the code working to do this. The problem is that the formatting tags display in Word rather than the actual formatting.

How do I get the format of the pasted text to display rather than the tags?

Here's the function I'm using along with the code that calls the function:

I'm pretty sure the clipboard.settext(text, format) method needs to have the format set to Rich Text. But I can't find the correct way to set the format to Rich Text. All of the examples I've seen are for VB.NET.

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

1. What is this "cleantext()" function..?
If you just do this what happens:
clipboard.SetText rst2!Dep_Elig_Def

2. You are using these lines:
.ClearFormatting
.Replacement.ClearFormatting
What is the result if you comment out these lines...

JeffCoachman

0

PerfishentAuthor Commented: 2013-09-26

Cleantext() is a custom function that trims the text, replaces apostrophes, and removes any non-printable characters.

If I remove the ClearFormatting lines, the replacement text still displays the html code the same as before:

divfont face=Arial size=2 color=blackThe Subscribers legal spouse or an unmarried dependent child of the Subscriber or the Subscribers spouse. The term child includes any of the following/font/divdivfont face=Arial size=2 color=black&nbsp/font/divul lifont face=Arial size=2 color=blackA natural child, including a newborn child from the moment of birth./font/li lifont face=Arial size=2 color=blackA stepchild./font/li lifont face=Arial size=2 color=blackA legally adopted child./font/li lifont face=Arial size=2 color=blackA child placed for adoption, beginning from/font/li lifont face=Arial size=2 color=blackThe moment of birth, if placement for adoption occurs within 30 days of the childs birth./font/li lifont face=Arial size=2 color=blackThe date of placement, if placement for adoption occurs within 31 or more days after the childs birth./font/li lifont face=Arial size=2 color=blackA child for whom legal guardianship has been awarded to the Subscriber or the Subscribers spouse./font/li/uldivfont

0

PerfishentAuthor Commented: 2013-09-26

The application takes text stored in a Rich Text memo field and pastes the text into Word. I have some placeholder text in Word that shows where the replacement text should go.

I just suggested those things as they seemed like a good place to start investigating...

0

PerfishentAuthor Commented: 2013-10-17

I never could get the clipboard.settext() method to preserve the rich text formatting entered into the Memo fields in Access. I had to change the fields to plain text in order to get the application to work correctly.