Hi, I have quite a lot of documents to amend and house style and one of the tasks is deleting all wording within {Note } and I wondered whether a macro would do the job. I have attached an example document. Any help would be very much appreciated. Thanks Shelley
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Macro to delete certain wording within curly brackets (braces)
Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Macro to delete certain wording within curly brackets (braces)
- This topic has 12 replies, 4 voices, and was last updated 8 years, 2 months ago.
AuthorTopicWSLady-Laughsalot
AskWoody LoungerMarch 9, 2017 at 4:25 am #508357Viewing 7 reply threadsAuthorReplies-
Charles Kenyon
AskWoody Lounger -
access-mdb
AskWoody MVPMarch 9, 2017 at 8:01 am #1593045I’ve just done a test on your Word Doc. On the Replace tab of find, click on more , then click on Use wildcards. The strings I entered are on the attachment. What you replace it with is up to you (you say words within the curly braces). Leave the replace field blank to replace the string with, well nothing.
The back slashes are required because { and } are special characters
Eliminate spare time: start programming PowerShell
-
WSLady-Laughsalot
AskWoody LoungerMarch 9, 2017 at 12:16 pm #1593065 -
access-mdb
AskWoody MVPMarch 9, 2017 at 1:27 pm #1593072OK, next iteration. You need to use {Note*} to find the relevant text. The capital of Note is required. Something to be aware of is that when it finds the string, it will put the final } at the top of the string (I’m assuming that the first time through you’ll do a find first before the replace to check it’s picking up the right text). Once you’re happy it’s doing what you want then a ‘replace all’ will be in order. When I did a replace all it removed 7 blocks of text – I assume that’s how many were in it.
Good luck!Eliminate spare time: start programming PowerShell
-
macropod
AskWoody_MVPMarch 9, 2017 at 5:52 pm #1593084You can’t specify the background shading as a Find/Replace parameter, besides which, the content you want to delete doesn’t all have that shading (e.g. {Note … }).
The basic Find/Replace macro code you’d incorporate into your larger process would be something like:
Code:With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "{Note*}" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchWildcards = True .Execute Replace:=wdReplaceAll End With
If the shading is an issue, another approach will be required.
Cheers,
Paul Edstein
[Fmr MS MVP - Word] -
WSLady-Laughsalot
AskWoody LoungerMarch 10, 2017 at 5:18 am #1593093You can’t specify the background shading as a Find/Replace parameter, besides which, the content you want to delete doesn’t all have that shading (e.g. {Note … }).
The basic Find/Replace macro code you’d incorporate into your larger process would be something like:
Code:With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "{Note*}" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchWildcards = True .Execute Replace:=wdReplaceAll End With
If the shading is an issue, another approach will be required.
Hi, many thanks for your responses to my query on this very much appreciated. I have managed to do a find and replace. There are a few places where the notes have not deleted and I can’t understand why. I’ve also added into the macro to delete the extra paragraphs. I attach an original document before I’ve run the macro and an updated document where I have run the macro. Thanks. Shelley
Code:Sub DPU_deletenotesdwf() ‘ ‘ DPU_deletenotesdwf Macro ‘ ‘ Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = “{Note*}” .Replacement.Text = “” .Forward = True .Wrap = wdFindContinue .Format = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Selection.WholeStory Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = “[^13]{2,}” .Replacement.Text = “^p” .Forward = True .Wrap = wdFindContinue .Format = False .Forward = True .MatchWildcards = True .Wrap = wdFindContinue End With Selection.Find.Execute Replace:=wdReplaceAll End Sub
-
access-mdb
AskWoody MVPMarch 10, 2017 at 5:38 am #1593094Shelley, I found one where it didn’t delete completely (under Charge) and that didn’t because there’s an embedded {} in the note – and neither my, or the macro’s methods can cope with that as they would terminate the find after 1s}
{Note
Charge{chargeNum IsMoreThan 1s}
List here those financial charges that are intended to be discharged on or before completion, so that the Property will be sold free of them. The definition is used primarily in relation to clause 8.
}Doing it my way you would have to check for those sorts of constructs. Perhaps Paul would be able to add such a thing to his macro (that’s beyond my pay-scale!)
Eliminate spare time: start programming PowerShell
-
WSLady-Laughsalot
AskWoody LoungerMarch 10, 2017 at 5:59 am #1593098I know what you mean about pay scale, I’m just a secretary trying to fathom this out with no support from IT so I really do appreciate all the help I get from here its made a massive difference to how I can get the mountain of work done and I can’t thank everyone enough really. Thanks for your help. Shelley
macropod
AskWoody_MVPMarch 11, 2017 at 1:20 am #1593263There is no practical way of extending the range to accommodate nested braces other than testing the found range, checking for any opening braces after ‘Note’ then extending by however many times as are necessary until one ends up with a matching count of opening and closing braces. That would require quite a different approach than what till now was a fairly simple Find/Replace.
PS: Shelley, I’d have thought by now – especially after all the code you’ve been given (or at least helped with) – you’d have learnt to do better than just use the macro recorder. All that ‘Selection’ stuff makes my eyes water.
Cheers,
Paul Edstein
[Fmr MS MVP - Word]-
WSLady-Laughsalot
AskWoody Lounger
macropod
AskWoody_MVPMarch 13, 2017 at 7:11 am #1593350Try:
Code:Sub Demo() Application.ScreenUpdating = False With ActiveDocument.Range With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "{Note*}" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchWildcards = True .Execute End With Do While .Find.Found Do While Len(Replace(.Text, "{", "")) Len(Replace(.Text, "}", "")) .MoveEndUntil "}", wdForward: .End = .End + 1 Loop .Delete .Collapse wdCollapseEnd .Find.Execute Loop End With Application.ScreenUpdating = True End Sub
Cheers,
Paul Edstein
[Fmr MS MVP - Word]-
WSLady-Laughsalot
AskWoody Lounger
Viewing 7 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Frustrating search behavior with Outlook
by
MrJimPhelps
15 minutes ago -
June 2025 Office non-Security Updates
by
PKCano
3 hours, 28 minutes ago -
Secure Boot Update Fails after KB5058405 Installed
by
SteveIT
33 minutes ago -
Firefox Red Panda Fun Stuff
by
Lars220
3 hours, 24 minutes ago -
How start headers and page numbers on page 3?
by
Davidhs
13 hours, 48 minutes ago -
Attack on LexisNexis Risk Solutions exposes data on 300k +
by
Nibbled To Death By Ducks
8 hours, 23 minutes ago -
Windows 11 Insider Preview build 26200.5622 released to DEV
by
joep517
22 hours, 29 minutes ago -
Windows 11 Insider Preview build 26120.4230 (24H2) released to BETA
by
joep517
22 hours, 31 minutes ago -
MS Excel 2019 Now Prompts to Back Up With OneDrive
by
lmacri
12 hours, 12 minutes ago -
Firefox 139
by
Charlie
4 hours, 47 minutes ago -
Who knows what?
by
Will Fastie
36 minutes ago -
My top ten underappreciated features in Office
by
Peter Deegan
23 hours, 14 minutes ago -
WAU Manager — It’s your computer, you are in charge!
by
Deanna McElveen
17 hours, 38 minutes ago -
Misbehaving devices
by
Susan Bradley
1 day, 1 hour ago -
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
2 days, 5 hours ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
2 hours, 31 minutes ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
2 days, 3 hours ago -
Discover the Best AI Tools for Everything
by
Alex5723
1 day, 2 hours ago -
Edge Seems To Be Gaining Weight
by
bbearren
1 day, 18 hours ago -
Rufus is available from the MSFT Store
by
PL1
2 days, 2 hours ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
3 days, 4 hours ago -
KB5061768 update for Intel vPro processor
by
drmark
1 day, 4 hours ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
1 day, 3 hours ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
3 days ago -
Office gets current release
by
Susan Bradley
3 days, 3 hours ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
4 days, 17 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
4 days, 1 hour ago -
Stop the OneDrive defaults
by
CWBillow
4 days, 18 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
5 days, 4 hours ago -
X Suspends Encrypted DMs
by
Alex5723
5 days, 6 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.