Macro to move Brackets

L

LEU

I need to create a macro that moves the brackets in our procedures to the
Right indent. Below are three examples from a procedure.


This procedure applies to all procedures which affect operations and ISFSI
including, but not limited to, the procedures required by CGS Technical
Specification 5.4.
{R-326}, {R-1413}, {R-1414}, {R-1420},
{R-1421}, {R-3721}, {R-11241},
{R-11312}, {R-11315}, {R-11323},
{R-11329}, {R-11429}

Cross-Discipline Reviewers are responsible for performing a
discipline-specific review of the procedure in their area of
expertise.{R-321}, {R-2436}

Shall review the procedure or revision changes per the Procedure
Verification and Validation Checklist, Attachment 7.3{C-7945}


I tried the follow but it didn’t work: With one set of brackets it work
fine, but when there is two or more, it put the next set of brackets out past
the right indent with a tab between each one.


Dim Msg, Style, Title, Response, MyString
Msg = " DOES THIS PROCEDURE HAVE SIGNOFF LINES?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "French Brackets"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
With SearchRange.Find
.Text = "^?{"
With Selection.Paragraphs.TabStops
.Add Position:=InchesToPoints(6.4), Alignment:=wdAlignTabRight
End With
.Replacement.Text = vbTab & "{"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
Else ' User chose No.
With SearchRange.Find
.Text = "^?{"
With Selection.Paragraphs.TabStops
.Add Position:=InchesToPoints(6.9), Alignment:=wdAlignTabRight
End With
.Replacement.Text = vbTab & "{"
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
End If
 
D

Doug Robbins - Word MVP on news.microsoft.com

Use

Dim myRange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="{", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True
Set myRange = Selection.Paragraphs(1).Range
myRange.Paragraphs(1).TabStops.Add InchesToPoints(6.4),
wdAlignTabRight
Selection.InsertBefore vbTab
myRange.Select
Selection.Collapse wdCollapseEnd
Loop
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top