Hello to all,
I hope every one is doing great this evening.
I have come back to ask for some help.
This may be a regex problem, that I have become confused with again, or there may be another way to do this but I am not very sure.
I am going through my documents that have specific words that need to have a font color applied to it.
The words have a code in front.
Sample Example
**2 Daniel - Name
**8 Joe - Surname
**3 Town - Name
**2 ReportID - Details
I need to find the specific words that have a
- ** in front and then give each word next to it a different RGB Font Color and make it bold.
- Delete the original code.
Example
Before
**3 Town - Name
**2 ReportID - Details
After
Town - Name
ReportID - Details
I only need The first word to have the RGB font color applied to it.
I am not very regex fluent. I have got stuck and just don't know how to move forward.
I have got these all over and - that is a lot of coloring to do - as you may imagine, finding the ** followed by numbers.
I thought I would try the VBA again.
Sub FindText
'Find Text that has a code infront
Dim myText As Word.Range
Set myText = ActiveDocument.Range
With myText.Find
For Each mytext In ActiveDocument
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.myText = "(**)[1][0-9]{1,}"
.Replacement.Text = ""
If InStr(1, myText.Range.Text, "**2") = 1 Then
myText.Range.Font.Color = RGB(40, 202, 67)
myText.Bold = True
Delete the **2
ElseIf InStr(1, myText.Range.Text, "**3") = 1 Then
myText.Range.Font.Color = RGB(91, 155, 213)
myText.Bold = True
Delete the **3
ElseIf InStr(1, myText.Range.Text, "**8") = 1 Then
myText.Range.Font.Color = RGB(235, 11, 213)
myText.Bold = True
Delete the **8
Else
Nothing
End if
End Sub
I just don't know what else to do.
I would be so grateful for the expert opinion on my offering - which is not looking very good at the moment. Saying that I have spent the whole day trying to learn about regex .
I also have a feeling that the instr(function) may not be the best?
So very grateful for the help.
thank you so much in advance for helping me again.
Saphire