Hello,
to all this Monday.
I hope everyone is doing great today
I have encountered a text font problem today.
I thought it was simple enough - so I attempted to code it, however something is not quite right.
My document has
text that is different colored , it may be 1 word or a string of words.
I simply wanted to
insert some placeholders before and after these words.
I thought it would be a simple feat.
However the VBA dragon is strong today - I just can't get it to work.
My attempt at coding this:
Code:
Sub FontColorPlaceholders()
'Find the RGB Font Color of Specific Text - Insert editing Placeholders
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
intPosition = oRng.End
oRng.Start = intPosition
With oRng.Find
.Text = " "
If oRng.Font.Color = RGB(255, 0, 102) Then
oRng.InsertBefore "[KEEP]" & vbCrLf
oRng.InsertAfter "[END]" & vbCrLf
ElseIf oRng.Font.Color = RGB(255, 0, 102) Then
oRng.InsertBefore "[EDIT]" & vbCrLf
oRng.InsertAfter "[END]" & vbCrLf
ElseIf oRng.Font.Color = RGB(0, 176, 240) Then
oRng.InsertBefore "[MOVE]" & vbCrLf
oRng.InsertAfter "[END]" & vbCrLf
' Some more if elses ........
End If
End With
End Sub
I've tried a number of other ways to get this to work, but now I've become confused between the text, string, paragraph and range objects.
I would be so grateful for some help.
Thank you so much for your help
J