Word 2003 "Not Responding" after Find and Replace

R

RCHaynes

Hi, I'm cross-posting with a vengeance attempting to solve a problem.
I have a log file, that I'm trying to use macros to reformat and segregate
into seperate files. All my subs except one work.

Sub ConvertParagraphs2LineFeeds()
'
' reformat all Paragraphs to Line Feed characters.
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p"
.Replacement.Text = "^l"
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub

When I step through it, everything works until I hit the End Sub statement.
I can see in the doc that all the paragraphs have become linefeeds. But I
can't get the focus back onto the doc. I've even waited for up to 30 minutes,
to see if it just needed to finish repaginating or something.
No matter what I do Word hangs. I have a growth in memory, but I never get
past the 'Not Responding' in Task Manager until I end the process.
I have the same reaction when I try to enter the ^p ^l in the Find and
Replace interface from the Edit menu, so I am suspecting that Word is somehow
skewed, not my macro.
Anyone have any insight?
 
H

Helmut Weber

Hi,

you cannot replace *all* paragraph marks
by whatever, at least not without creating
a new paragaph mark at the docs end,
the doc-end-mark,
which leads to an endless loop.

Sub Test004()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
rDcm.End = rDcm.End - 1
With rDcm.Find
.Text = "^p"
.Replacement.Text = "^l"
.Execute Replace:=wdReplaceAll
End With
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

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

RCHaynes

Thanks muchly for the input!
Alas, even though I can see in the document pane that all *but the last ^p*
are now LineFeed characters (^l or ^11), I am still locking the application.

I am beginning to suspect either my install is corrupt, or the file is. I'll
try again tomorrow with a fgresh file while I get support on the horn.

RCH
 
K

Klaus Linke

Hi,

I'm wondering if Word really hangs... Have you tried Ctrl+Pause to stop your
macro (in case it's still running)?
Maybe you've programmed some endless loop by accident.

Regards,
Klaus
 
R

RCHaynes

Well, in other news...
I was distracted from this project to fillin some man-month hours for
something and wasn't able to pursue this.

I finally got a supportdesk guy down here, and after uninstalling and
reinstalling MS Office, tries remoiving some of the KB updates.
LO!
The Find and Replace worked (preserving the EoF ^p as well)

Yes, a 'real' tool for parsing would be *vastly* preferable. But, corporate
restrictions and all.... and, if I did use another tool, then it's 20
licenses for the other engineers in our group to use it.
Now to figure out how to disinclude a list of 'titles' that I just want to
exit the loop after cutting to poick up the next paste. Maybe I just want to
go into the Do and paste it, and just close without saving when titles are
such trivial things as 'null'

Thank yopu everyone for your help with this. I really appreciate all the
time you offered to help me with my problem.

Robin Haynes
 

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