Public Enum RT_FormatType
RT_Bold = 1
RT_Underline = 2
RT_Italic = 3
RT_Red = 4
RT_Blue = 5
RT_BoldUnderline = 6
RT_YellowHighlight = 7
End Enum
Public Function FormatWord(searchIn As String, searchFor As String, FormatType As RT_FormatType)
Dim replaceText As String
Select Case FormatType
Case RT_Bold
replaceText = "<strong>" & searchFor & "</strong>"
Case RT_Underline
replaceText = "<u>" & searchFor & "</u>"
Case RT_Italic
replaceText = "<em>" & searchFor & "</em>"
Case RT_Red
replaceText = "<font color=red>" & searchFor & "</font>"
Case RT_Blue
replaceText = "<font color=Blue>" & searchFor & "</font>"
Case RT_BoldUnderline
replaceText = "<strong>" & searchFor & "</strong>"
replaceText = "<u>" & replaceText & "</u>"
Case RT_YellowHighlight
replaceText = "<font style= 'BACKGROUND-COLOR:#FFFF00'>" & searchFor & "</font>"
Case Else
replaceText = searchFor
End Select
searchIn = Replace(searchIn, searchFor, replaceText)
FormatWord = searchIn
End Function
Public Sub TestFormat()
Debug.Print FormatWord("dog", "The dog ran", RT_Bold)
End Sub