Hi, the multiple text color is not possible using textbox but can do using additional control "
Microsoft InkEdit Control" (see image)
View attachment 66316
The output would be as below.
View attachment 66314
Below is the macro used to display the text inside double quotes in RED font.
- The InkEdit control name is inktext.
- Chr(34) is used for double quotes.
VBA Code:
Private Sub UserForm_Activate()
Dim firstpos As Integer, lastpos As Integer
inktext.Text = "And Jesus Said to him," & Chr(34) & _
"therefore when you see the abomination of desolation standing in the Holy Place." & Chr(34) & _
"(let the reader understand) Matthew 24:15"
inktext.SelStart = 0
inktext.SelLength = Len(inktext.Text)
inktext.SelColor = vbBlue
inktext.SelFontSize = 18
firstpos = InStr(1, inktext.Text, Chr(34))
lastpos = InStr(firstpos + 1, inktext.Text, Chr(34))
inktext.SelStart = firstpos
inktext.SelLength = lastpos - firstpos - 1
inktext.SelColor = vbRed
inktext.SelLength = 0
End Sub
Saurabh - thanks - I've been at this for what seems like a thousand years. Will study and copy your
code shortly. If this works as you indicate, I would apply this of course to the entire New Testament
where all the words of Jesus within surrounding text are in red. About 160 location blocks.
cr
Hi, the multiple text color is not possible using textbox but can do using additional control "
Microsoft InkEdit Control" (see image)
View attachment 66316
The output would be as below.
View attachment 66314
Below is the macro used to display the text inside double quotes in RED font.
- The InkEdit control name is inktext.
- Chr(34) is used for double quotes.
VBA Code:
Private Sub UserForm_Activate()
Dim firstpos As Integer, lastpos As Integer
inktext.Text = "And Jesus Said to him," & Chr(34) & _
"therefore when you see the abomination of desolation standing in the Holy Place." & Chr(34) & _
"(let the reader understand) Matthew 24:15"
inktext.SelStart = 0
inktext.SelLength = Len(inktext.Text)
inktext.SelColor = vbBlue
inktext.SelFontSize = 18
firstpos = InStr(1, inktext.Text, Chr(34))
lastpos = InStr(firstpos + 1, inktext.Text, Chr(34))
inktext.SelStart = firstpos
inktext.SelLength = lastpos - firstpos - 1
inktext.SelColor = vbRed
inktext.SelLength = 0
End Sub
Saurabh - thanks a mil. I'm going to study and copy this code into the UF's Activate event.
There are about 160 locations from Matt-John I want to do this for. So this defines a range.
If I can duplicate what you indicated above, the effort would be well worth it, if it has to be
done as one section of text at a time. However - my initial thought would be to write a FIND
code block that finds all the text within a defined range that begins with "Jesus said" and apply this code;
as I understand your code, the FIND code would have to know where to start applying red text and where to stop
applying red text, and that would be between quotes, [start red text here] "......"[stop red text here].
If this is able to be done with a FIND code correctly, it would complete the task very quickly.
Please let me know if I'm approaching this correctly.
Thanks again. Exciting to be able to do this at last! cr