Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2007

Tip: Looking for answers? Try searching our database.

Fastest way to change vbCr to vbCrLf?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Benjamino5 - 23 Jul 2007 21:32 GMT
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 - 23 Jul 2007 21:58 GMT
Read this, http://tinyurl.com/yrdata
and also there's a link to the Word MVP site about searching using
wildcards.
Benjamino5 - 23 Jul 2007 22:28 GMT
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

> Read this, http://tinyurl.com/yrdata
>  and also there's a link to the Word MVP site about searching using
> wildcards.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.