Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically Inserting Brackets to EACH selected line (Word Doc.)

Status
Not open for further replies.

ar100m

MIS
May 16, 2021
1
EG
Hello guys,

I need to ask if it's possible to do amend on the below code related to Inserting Brackets I need to add the brackets in each bold sentences after selecting the same format

Sub AddBrackets()
Dim iCount As Integer
iCount = 1
While Right(Selection.Text, 1) = " " Or _
Right(Selection.Text, 1) = Chr(13)
Selection.MoveLeft Unit:=wdCharacter, Count:=1, _
Extend:=wdExtend
iCount = iCount + 1
Wend

Selection.InsertAfter "]"
Selection.InsertBefore "["
Selection.MoveRight Unit:=wdCharacter, Count:=iCount
End Sub

ezgif-1-06c2f5dd27a5_loypi6.png


The problem with the code now it's adding the brackets for the last line only do you know or if it's possible to help on how I can add to each bold sentence only ?
I would be appreciated for your time and effort

Attachments area
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top