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_Product ion.value = nukefontsize_in_rtf(Me.txt ProjectNot es_Product ion.Value)
Function nukefontsize_in_rtf(strtex t 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
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_Product
Function nukefontsize_in_rtf(strtex
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
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
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.
The code above seems almost there... but I think there is something missing - or maybe an alternative approach.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
found this on a Microsoft blog
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