View Single Post
 
Old 03-19-2022, 09:54 PM
Bikram Bikram is offline Windows 10 Office 2007
Advanced Beginner
 
Join Date: Jul 2021
Location: Nepal
Posts: 97
Bikram is on a distinguished road
Default

I am very grateful for your reply, Paul. I am sorry that I failed to describe in detail the question or problem. I was trying to insert commas inside numerical figures and trying to code like if the numerical text lies within field {(eq /f(2150,2204)} then ignore the comma.

Again, I want to thank you for your effort.

Your code flags every character as True whether it is inside the field or not.
However, I found a way to get my work done but it may be lengthy and error prone.

Code:
   If .Range.Characters(1).Previous.Text = "." Or .Range.Characters(1).Previous.Text = "," Or .Range.Characters(1).Previous.Previous.Text = "‚" Then
    rng.Fields.ToggleShowCodes
    Selection.MoveRight wdWord, 1, wdExtend
  
     If Selection.Range.Fields.Count = 1 Then ' I used this approach, it is manual but get the jobs done
    rng.Fields.ToggleShowCodes
    rng.Select
    GoTo exx
    Else
    rng.HighlightColorIndex = wdRed
    Selection.MoveRight wdCharacter, 1
    End If
Reply With Quote