Replace Web Returns By Proper Returns

B

Bob Phillips

If you open an HTML page in Word, I often find a sort of hanging return,
rather than a LfCr. This means that it doesn't take the style as I want, so
I would like to do a global replace on them. Anyone know what the character
to replace is?

TIA

Bob
 
J

Jezebel

It's a linefeed (vbLF). You can zap them using Find and Replace (^l) or use
AutoFormat.
 
H

Helmut Weber

Hi Bob,

I'd say most often these are chr(13).
A chr(13) is not a paragraph mark!
It is more, which explains, that
each paragraph mark is to be found,
when searching for chr(13).


Create new word doc with this text,
and with nothing else:

The quick brown fox jumps over the lazy dog.¶
The quick brown fox jumps over the lazy dog.¶
The quick brown fox jumps over the lazy dog.¶

Sub Test001()
selection.WholeStory
With selection.Find
.Text = "x"
.Replacement.Text = vbCr
.Execute Replace:=wdReplaceAll
End With
selection.WholeStory
MsgBox selection.Paragraphs.Count ' 3 !
End Sub

There are seeambly 7 paragraphs,
though paragraphs.count returns still 3.

Now let this follow:

Sub Test002()
selection.WholeStory
With selection.Find
.Text = Chr(13)
.Replacement.Text = "^p"
.Execute Replace:=wdReplaceAll
End With
selection.WholeStory
MsgBox selection.Paragraphs.Count ' 7 !
End Sub

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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