Find method rebound sometimes

A

Antonio Pérez

Hello :

I have a document with paragraphs and tables, in some cases I have nothing
( only a carriage return symbol ), but ( because many people worked in the
docs ) it has a style I want to change.

I have a macro to find all these cases but my 'do... loop macro' rebound
eternally when find those cases. I fix the problem making :

Selection.MoveRight(Unit:=wdCharacter, Count:=1)
Selection.MoveDown(Unit:=wdLine, Count:=1)

but it is not the solution ( in addition it fails )

Some idea ???
Antonio Pérez
 
H

Helmut Weber

Hi Antonio,

hm...

I think you should rather post the code that causes the problem
than your attempts at solving them. ;-)

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
A

Antonio Pérez

Here you are :

'-----------------------------------------------------------------------------------------------------

Selection.HomeKey wdStory ' go to top
Selection.Find.ClearFormatting

With Selection.Find
.Style = 'somestyle'
.Text = " "
Do
ok = .Execute(, , , , , , True, wdFindStop)
Loop While ok = True

End With
'---------------------------------------------------------------------------------------------------------
I'm going to explain it again :
In certain situations my code work fine, however inside tables or when I
have only a 'enter' or carriage return this macro find allways the same
solution.

thanks
 
H

Helmut Weber

Hi Antonio,

This should cure the problems in tables:
[snip]
Do
ok = .Execute(, , , , , , True, wdFindStop)
If Selection.Information(wdWithInTable) = True Then
Selection.EndKey
End If

Loop While ok = True
[snip]

However, I couldn't reproduce other endless loops.

Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 

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