Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-16-2021, 07:03 PM
ar100j ar100j is offline Automatically Inserting Brackets to EACH selected line Windows 10 Automatically Inserting Brackets to EACH selected line Office 2019
Novice
Automatically Inserting Brackets to EACH selected line
 
Join Date: May 2021
Posts: 3
ar100j is on a distinguished road
Lightbulb Automatically Inserting Brackets to EACH selected line

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


Quote:
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


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
Reply With Quote
 

Tags
macro edit, macro multiple functions



Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax for inserting blank line before inserting table and after a line or paragraph SamDsouza Word VBA 8 08-04-2019 11:10 PM
How to move a line to another line that starts with a chain selected in the 1st one? gloub Word VBA 24 03-19-2019 03:12 PM
Automatically Inserting Brackets to EACH selected line find and delet all text within brackets and the brackets themselves wrdy Word 2 08-03-2017 06:55 PM
Automatically Inserting Brackets to EACH selected line macro to add brackets to each line and add single quotes to each word in the line bracketandquotes Word VBA 17 02-16-2015 03:51 PM
Inserting nested brackets in a field code deletes numeration piotrek99 Word 1 11-02-2014 01:15 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft