Clean up Word formatting in Access form

Dear Experts

I am building a newsletter database where the user will copy paste stories into a form from word.  The field where the text is pasted is set to rich text field.  

I am keen to remove all html formatting (e.g. font color, size hyperlinks, underlines) from the field with the exception of a couple of mark ups (namely <Strong> </strong> & paragraph marks) ...

Is there a way to do this?

Many thanks
Who is Participating?
IrogSintaConnect With a Mentor Commented:
So it would be something like this:

Dim strTemp as String

strTemp = [YourTextFromWord]
strTemp = Replace (strTemp, "<Strong>", "#Strong#") 
strTemp = Replace (strTemp, "</Strong>", "#/Strong#")

strTemp = =PlainText(strTemp)
strTemp = Replace (strTemp, ,"#Strong#", "<Strong>") 
strTemp = Replace (strTemp, "#/Strong#", "</Strong>")

Open in new window

Try using the PlainText() function to remove the HTML tags.
correlateAuthor Commented:
Hi IrogSinta,

Thanks for that, it covers everything I want it to do except it removes the bold from text & I'm keen to keep that in there
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

correlateAuthor Commented:
So had a few further thoughts on how to crack this ...

I have made a calculated field (called "Formatted") which takes the text from the field I am trying to manipulate ([Body]) and displays it with all the tags. All I need to do now is copy the text from formatted into a string, manipulate it and then place it into a new field.

To make the manipulation easier I was thinking of deploying the following logic, but had no real idea how to code this.

1. Find & Replace <Strong> to #Strong# & </strong> to #/strong# (i.e. the tags I want to keep)

2. Trim everything that appears between "<" & ">"

3. Then do another find & replace #Strong# to <Strong> & #/strong# to </strong> (to reinstate those tags)

4. Paste the result into the new field

No sure if this helps?
correlateAuthor Commented:
Perfect - thank you very much - works a treat
You're quite welcome.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.