I wonder if any VBA experts can help - I appreciate this applies to MS Word. I found the following macro to remove square brackets.
Sub RemoveSquareBrackets()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Text = "\[*\]"
.MatchWildcards = True
While .Execute
With oRng
.Select
Select Case MsgBox("Do you want to remove brackets?", vbQuestion + vbYesNoCancel, "???")
Case Is = vbYes
.Characters.First.Delete
.Characters.Last.Delete
.Collapse wdCollapseEnd
Case Is = vbNo
.Collapse wdCollapseEnd
Case Else
Exit Sub
End Select
End With
Wend
End With
lbl_Exit:
Exit Sub
End Sub
I want a simpler macro that simply removes the first brackets to the left and right of the cursor (i.e. just one pair of brackets) and does not cycle through the document. If there are no brackets or only a single bracket then a pop up to give a warning.
Many thanks in advance.
Sub RemoveSquareBrackets()
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.ClearFormatting
.Text = "\[*\]"
.MatchWildcards = True
While .Execute
With oRng
.Select
Select Case MsgBox("Do you want to remove brackets?", vbQuestion + vbYesNoCancel, "???")
Case Is = vbYes
.Characters.First.Delete
.Characters.Last.Delete
.Collapse wdCollapseEnd
Case Is = vbNo
.Collapse wdCollapseEnd
Case Else
Exit Sub
End Select
End With
Wend
End With
lbl_Exit:
Exit Sub
End Sub
I want a simpler macro that simply removes the first brackets to the left and right of the cursor (i.e. just one pair of brackets) and does not cycle through the document. If there are no brackets or only a single bracket then a pop up to give a warning.
Many thanks in advance.