Avatar of terpsichore
terpsichore asked on

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:

CALLING THE FUNCTION:

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

   
    Do
        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
Microsoft AccessHTMLWeb Languages and Standards

Avatar of undefined
Last Comment
terpsichore

8/22/2022 - Mon
Jeffrey Coachman

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

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
ASKER
terpsichore

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.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
terpsichore

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
terpsichore

found this on a Microsoft blog