Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and Reposition Text question

Status
Not open for further replies.

pluz

Instructor
Jan 26, 2004
20
0
0
US
Elementary VB question (for you, that is):
I recorded the following macro in Word 2003 to find a dashed line and move it up one position up from its current position:

Selection.Find.ClearFormatting
With Selection.Find
.Text = "____________________________________________________"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute
Selection.Range.Relocate wdRelocateUp

My Problem: There are many instances of the dashed line in my document, but this only works for the first instance, and I can't seem to figure out how to make it find and reposition every dashed line in the document.

Please help!
 
declare the search text (dashed line) as variable
declare range object
make range whole document
use range.find.execute findtext

or use
with activedocument.content.find
 
Hi pluz,

I don't have Word 2003 so can't check put the Relocate, but you probably just need a simple loop ..

Code:
[blue]Do While Selection.find.execute = true
    Selection.Range.Relocate wdRelocateUp
Loop[/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top