macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello!

I want to write a simple macro that will cut a line with a common phrase out
of a document and paste it all at the end. How do I write one that will
search for the phrase, block the whole line, then cut it and paste it at the
bottom? I got most of it down but I need to know how to make it repeat so I
don't have to keep running it myself, but so that it will run through the
whole document doing it.

thank you much!
 
Here's a macro that does something different, but it contains the Do While
..... Loop construction that you would used to repeat the operation that you
are talking about:

Dim myrange As Range
Dim myoptions As Variant
Dim ffield As FormField

Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(findText:="] [", Forward:=True, MatchWildcards:=False,
Wrap:=wdFindStop) = True
Set myrange = Selection.Paragraphs(1).Range
myrange.start = myrange.start + InStr(myrange, "[")
myrange.End = myrange.start + InStrRev(myrange, "]") - 1
myoptions = Split(myrange, "] [")
myrange.start = myrange.start - 1
myrange.End = myrange.End + 1
Set ffield = ActiveDocument.FormFields.Add(Range:=myrange,
Type:=wdFieldFormDropDown)
With ffield
For i = LBound(myoptions) To UBound(myoptions)
.DropDown.ListEntries.Add myoptions(i)
Next i
.Range.InsertBefore " "
End With
Loop
End With
ActiveDocument.Protect wdAllowOnlyFormFields


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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

Back
Top