Discussion:
Fastest way to change vbCr to vbCrLf?
(too old to reply)
Benjamino5
2007-07-23 20:32:05 UTC
Permalink
I have a batch of strangely corrupted Word files. Most of the paragraph marks
are actually just chr(13) a.k.a. vbCr, not the full combination vbCrLf,
a.k.a. vbCrLf.

This matters because when I save the Word files as RTF (which I have to do),
the chr(13)-only "paragraph marks" just disappear.

I thought I could do a find-and-replace for chr(13), replacing it with the
combo of chr(13) and chr(10), but Word's weird handling of this made it fail.

Instead, I'm going character by character, which takes a very LONG time:

Sub CharTest()
Dim x As Integer
Dim chars As Characters
Set chars = ActiveDocument.Characters
For x = 1 To ActiveDocument.Characters.Count
If chars.Item(x) = Chr(13) Then
chars.Item(x).text = Replace(chars.Item(x), Chr(13), Chr(13) &
Chr(10))
End If
Next x
End Sub

What would be a better way to do this?

Thanks a lot,
Ben
David Sisson
2007-07-23 20:58:40 UTC
Permalink
Read this, http://tinyurl.com/yrdata
and also there's a link to the Word MVP site about searching using
wildcards.
Benjamino5
2007-07-23 21:28:02 UTC
Permalink
David,

Thank you! The tip at the bottom of the thread about using wildcards and
replacing "^13" with "^p" did the job magnificently--and instantly.

Ben
Post by David Sisson
Read this, http://tinyurl.com/yrdata
and also there's a link to the Word MVP site about searching using
wildcards.
Loading...