Replacing paragraph mark with space

  • Thread starter Thread starter GregNga
  • Start date Start date
G

GregNga

Is there a macro or VB code available that will replace paragraph marks with
a space but only for selected text
 
Do you need to do this programmatically? It's easy enough to do with the
Replace dialog.
 
Select the text.

Press Ctrl+H.

Put ^p into Find what:

Type a space into Replace with.

Choose Replace All.

Say No to the prompt to search the rest of the document.
 
As others have said it is simple enough to do with Replace, but the macro
option is simple also

Sub ReplacePara()
Dim sText As Range
Set sText = Selection.Range
If Len(sText) = 0 Then
MsgBox "No text selected!", vbCritical
Exit Sub
End If
sText = Replace(sText, Chr(13), Chr(32))
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Probably a couple hundred keystrokes (on top of figuring out how to do
it, which may or may not be trivial), as opposed to a dozen keystrokes/
clicks.
 
The OP asked for a macro, which may mean that the operation is part of a
larger VBA project.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Probably a couple hundred keystrokes (on top of figuring out how to do
it, which may or may not be trivial), as opposed to a dozen keystrokes/
clicks.
 
Yes, I needed a macro. I have occasion to do this a lot as I copy and paste
into WORD from another source and so it ends up with a paragraph after each
line, so I wanted to make a toolbar button that will do this, hence a macro.

Thanks everyone
 
Word's AutoFormat command can do this, too... to the whole document or just
to selected text. It might give better results than a standalone macro. You
might look at the AutoFormat command. In Word 2007, look for AutoFormat Now,
and in Word 2003 and earlier, look for FormatAutoFormat.
 
Ctrl+C - ALT+F11 - Ctrl+V that's three keystrokes (or 6 if you count each
part as a separate keystroke).

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
So you're volunteering to write whatever macro anyone wants, so they
can copy-paste it into their system?
 
For someone who purports to have intelligence you sometimes behave like an
a***hole when your narrow view of things is challenged!. Of course I am not
going to produce a macro solution for everyone who asks, but if a simple
solution presents itself, I have the code to hand, or it is something that
stimulates my curiosity, I will provide it.

The OP asked for a vba solution to a problem and I provided one. He didn't
have to figure anything out for himself - he only had to copy it. No one is
forcing *you* to use macros if you prefer to do things using the toolbar
commands. Others, more open minded, may welcome them.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
It's driving a thumbtack with a sledgehammer.

For someone who purports to have intelligence you sometimes behave like an
a***hole when your narrow view of things is challenged!. Of course I am not
going to produce a macro solution for everyone who asks, but if a simple
solution presents itself,  I have the code to hand, or  it is something that
stimulates my curiosity, I will provide it.

The OP asked for a vba solution to a problem and I provided one. He didn't
have to figure anything out for himself - he only had to copy it. No one is
forcing *you* to use macros if you prefer to do things using the toolbar
commands. Others, more open minded, may welcome them.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

My web sitewww.gmayor.com
Word MVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
*Every* function in Word has had the benefit of a programmer putting
together the code that enables you to use the function. vba is included to
enhance and add to the built-in functions.Many of the users of these Word
forums are corporate employees who are required to perform the same
repetitive tasks. For such people a simple function dedicated to their task
saves time and effort.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top