Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

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
0
correlate
Asked:
correlate
  • 3
  • 3
1 Solution
 
IrogSintaCommented:
Try using the PlainText() function to remove the HTML tags.
=PlainText(NameOfFieldWithHTMLstring)
0
 
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
0
 
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?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
IrogSintaCommented:
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

0
 
correlateAuthor Commented:
Perfect - thank you very much - works a treat
0
 
IrogSintaCommented:
You're quite welcome.
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now