1 Attachment(s)
VBA Help with square bracket issue
I would be very grateful for some help with an issue in the code below. The code below is part of a larger macro but after stepping through each part of the code, this is the part that is causing the issue. This part of the code inserts bold quotes around bold definition words then inserts a tab after the closing bold quote (see attachment). The issue is if there is a square bracket at the beginning it doesn't insert a tab or if there was already a tab there before the code is run that tab is being removed, I'm really stumped on how to fix this so any help would be very much appreciated.
Code:
Set oRng = ActiveDocument.RangeWith oRng.Find
.Text = ""
.Replacement.Text = "^034^&^034"
.Font.Bold = True
.Format = True
.MatchWildcards = True
While .Execute
If Not InStr(oRng.Text, Chr(13)) Then
While oRng.Characters.Last = Chr(32)
oRng.Characters.Last.Font.Bold = False
oRng.End = oRng.End - 1
Wend
oRng.Text = Chr(34) & oRng.Text & Chr(34)
If oRng.Characters.First.Previous = Chr(13) Then
oRng.Collapse wdCollapseEnd
oRng.Font.Bold = False
oRng.Characters.Last = vbTab
Else
oRng.Collapse wdCollapseEnd
End If
End If
Wend
End With