Link to home
Start Free TrialLog in
Avatar of 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:


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
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

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
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
Avatar of 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.
Avatar of terpsichore

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
found this on a Microsoft blog