Custom toolbar button for search and replace

Joined
Apr 9, 2023
Messages
1
Reaction score
0
Hi. I often create Word documents for printing by pasting content from websites. The clipboard content usually contains many pairs of successive paragraph marks. To save paper I search and replace each instance of two paragraph marks with just one paragraph mark. I normally do this several times as there can be instances of five or six consecutive paragraph marks.
Can I make a button for the toolbar to do this for me? I'm using Word 2013.
Thanks for reading. Robert, Australia
 
Joined
Mar 26, 2023
Messages
4
Reaction score
0
You can save this VBA procedure to your Normal project and assign a QAT Button, Ribbon Button or keyboard shortcut to it:

Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oRng As Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = Chr(13) & "{2,}"
.MatchWildcards = True
.Replacement.Text = Chr(13)
.Execute Replace:=wdReplaceAll
End With
lbl_Exit:
Exit Sub
End Sub
 

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