Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 05-27-2021, 06:11 AM
Matt C's Avatar
Matt C Matt C is offline Enclose All Instances of a Specific Custom Style in Brackets Windows 10 Enclose All Instances of a Specific Custom Style in Brackets Office 97-2003
Advanced Beginner
Enclose All Instances of a Specific Custom Style in Brackets
 
Join Date: May 2021
Location: London, UK
Posts: 30
Matt C is on a distinguished road
Question Enclose All Instances of a Specific Custom Style in Brackets


Hi folks

I've been tinkering with the VBA code below which encloses curly brackets (parentheses) around selected text but am looking for a way to apply this method automatically to every paragraph in a document which is formatted with a specific custom style (let's call it "Custom Style").

Secondly, I then want to do the reverse (which can be a separate macro), i.e. remove left and right curly brackets from the beginning and end of "Custom Style" paragraphs).


Quote:
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
All help appreciated in advance. Many thanks.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Enclose All Instances of a Specific Custom Style in Brackets find and delet all text within brackets and the brackets themselves wrdy Word 2 08-03-2017 06:55 PM
Enclose All Instances of a Specific Custom Style in Brackets Word forces use of a specific style C_Hawk1996 Word 1 04-13-2016 05:35 AM
Enclose All Instances of a Specific Custom Style in Brackets How to set the left indent in a specific style. OfficeBoy95 Word 2 05-12-2014 06:31 PM
How do I add a custom style to tab button? kennethc Word 1 04-11-2014 05:25 PM
How to set style automatically for specific texts ragesz Word 2 07-25-2013 07:08 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:45 PM.


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