We help IT Professionals succeed at work.

Find and delete a variable number of spaces following  paragraph character

Dave Swarthout
on
122 Views
Last Modified: 2017-03-13
I receive some documents every week that need reformatting. They come with a mixture of non-breaking spaces and normal spaces at the beginning of each paragraph. I could use a simple Find & Replace (optionally embedded in a macro) to find the spurious characters and delete them but their number and distribution ae not the same week to week.

What I need is a few lines of code that find a paragraph mark and then somehow check each subsequent character and if it's a space delete it, continuing until a character in the range [A-Z] is reached. I will pre-process the docs to change all non-breaking spaces into normal spaces.

I'm working in Word 2003.

Thanks in advance.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2016

Commented:
Hi,

pls try (using wildcards)
in Find what:
^013(^0032)@

Open in new window

in Replace with
^013

Open in new window

Regards
Shaun VermaakSenior Consultant
CERTIFIED EXPERT
Awarded 2017
Distinguished Expert 2019

Commented:
Have you tried an "Advanced Search" with
^w^v

Open in new window

CERTIFIED EXPERT
Top Expert 2016

Commented:
or you could try (without wildcards)
Find what
^013^w

Open in new window

replace with
^p

Open in new window

so you do not have to change the non-breaking spaces in "normal" spaces
CERTIFIED EXPERT
Top Expert 2016
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks much. That macro worked wonderfully.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.