Need Macro to remove empty paragraph marks.

I

ISay

I have tried the Macros that are supposed to remove empty paragraphs but they
don't work and I've used find/replace. The problem is that the document is
left with paragraph marks which Word 2003 does not see/recognize. I even
tried removing all paragraph marks and ended up with the following:

and white beans1. Heat 2 tbsp of the olive oil in a large heavy-¶
based pan over a medium heat. Add the shallots ¶
and garlic to the pan. Cook gently for 5 minutes ¶
until well softened. Halve the tomatoes and chop ¶
the tomato flesh into chunky pieces. Stir the ¶
tomatoes and bay leaves into the pan and crumble ¶
the dried chillies over.2. Stir in the beans and 100 ml water. Season with ¶

It seems the only way to remove them is manually, not an option.

I thought of creating a macro to go to the end of the line and backspace
over the mark and add a space if needed but I don't know how to loop a macro
to the end of the document.

I have searched for a "how to" for looping but they are all specific to the
problem under discussion and I don't know how to use the information for
using it as I would like to. Can you create a macro for me and explain
exactly how to use it? Also tell me how to create a loop within any macro so
I can use it however I need.

I was born a blond and have no idea of Visual Basic. I've tried editing
macros but only ended up corrupting them because I don't know how to do it.
 
M

macropod

Hi ISay,

Ordinarily, Word expects a paragraph mark to consist of two characters - Hex OD & OA (ASCII 13 & 10). These constitute a carriage
return and line-feed pair. Sometimes, only the carriage return may be presnt, but Word will still display it as '¶'.

All you need to do to overcome this is to use '^13' in the 'Find' box and, if you want to replace it with a 'proper' paragraph
marker, '^p' in the 'Replace' box.
 
I

ISay

This works up to a point. I'm still left with a paragraph mark/carriage
return at the end of every line so that I cannot justify the text. I can
highlight each paragraph then run a replace to remove paragraph marks within
that paragraph which is more trouble than it is worth. I need a macro for
doing this.

I would also like to know how to create a loop within a macro to continue to
the end of the document.
 
M

macropod

Hi ISay,

You can use the Find/Replace codes I posted on the whole document (or however much of it you still need to process) at once -
there's no need to process each paragraph individually.

I suggest using a 5-step process:
First, make sure there are two paragraph marks (either '^13' or '^p', it doesn't matter) between the 'real' paragraphs.
The next 4 steps are done sequentially and consist of replacing all instances of :
.. '^13' with '^p'
.. '^p^p' with '!~!'
.. '^p' with ' '
.. '!~!' with '^p' (or '^p^p' if you want to retain two paragraph marks between the 'real' paragraphs).
If you really want to use a macro, record one with the macro recorder - it's fairly efficient in this case. However, it'll take
longer to record than to go through the last 4 steps! And it won't help with ensuring the required initial separation between the
'real' paragraphs.
 
I

ISay

This did not work. I think the problem is in your first step; the 'real'
paragraphs do not have two ¶ marks. (I used copy/paste to collect recipes
from the internet, each site has its own way of doing things wrongly for easy
editing.) Every line ends with a ¶; some are followed by an empty line with
only ¶.

I copy the recipes into Notepad until such time as I get around to editing
to put them in my recipe software program. There are carriage returns at the
end of every line but no empty lines in Notepad. When I copy/paste the text
document into Word, I have the empty lines. Is there a solution?
 
I

ISay

I have sent you two samples, before and after, to see what, if anything, you
can do. I have come to the conclusion that if I want to retain these recipes
I will have to manually edit them.

I keep a Notepad file iconized for saving recipes on the fly. When I have
the time/inclination, I open them in Word to edit them and add them to my
recipe software. That is where the problem lies, saving first to Notepad.
After experimenting, I can keep a WordPad file iconized and paste to that;
doing this, I do not lose the formatting which is creating the problems.

Thanks to you and macropod for trying to correct my problems.
 

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