RTF Memo - make font size consistent

Users continually paste text into various RTF memo fields - this works well, except they are now a hodgepodge of font sizes, some of them very large and hard to read.
I found the code below - which seemed to work, but doesn't really. It works the first time, but then when you, for example, change some local formatting (e.g., add some italic to a phrase), it seems to nuke the memo field altogether -
any ideas are appreciated:


Me.txtProjectNotes_Production.value = nukefontsize_in_rtf(Me.txtProjectNotes_Production.Value)

Function nukefontsize_in_rtf(strtext As String) As String

    Dim lngTagStart As Long
    Dim lngTagEnd As Long
    Dim blnReset As Boolean

        lngTagStart = InStr(strtext, "<font")
        If lngTagStart > 0 Then
            lngTagEnd = InStr(lngTagStart, strtext, ">")
            strtext = left$(strtext, lngTagStart - 1) & Mid$(strtext, lngTagEnd + 1)
            blnReset = True
        End If
    Loop Until lngTagStart = 0

    If blnReset Then
        strtext = Replace(strtext, "</font>", vbNullString)
        nukefontsize_in_rtf = strtext
    End If
End Function
Who is Participating?
terpsichoreConnect With a Mentor Author Commented:
Jeffrey CoachmanMIS LiasonCommented:
Perhaps an expert more familiar with HTML and HTML tags can help with modifying that code...

In the meantime you can "make" the text all look the same by creating a query of the table and adding in a field that will ignore all the formatting and present the memo field as plain text...

Something like this:
SELECT Fld1, Fld2, YourMemoField, Plaintext(YourMemoField) as PlainMemo
FROM YourTable
David Johnson, CD, MVPOwnerCommented:
Don't make it a rtf editor but just a plain-text editor..  or as noted above strip all formatting and only use the plain-text
terpsichoreAuthor Commented:
well, we would like to have local formatting (bold, italic, underline, bullet list) but without the differing point sizes.
The code above seems almost there... but I think there is something missing - or maybe an alternative approach.
terpsichoreAuthor Commented:
found this on a Microsoft blog
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.