Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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! -- Jenn |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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 "Jennifer" wrote in message ... 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! -- Jenn |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro cannot be found or has been disabled because of Macro settin | Microsoft Word Help | |||
Pause an executing Word Macro to enter info and then Macro continu | Microsoft Word Help | |||
macro runs from keyboard, but not from macro button-why? | Microsoft Word Help | |||
Running Macro from Word vs running macro from vb.net prog | New Users | |||
2000 to 2002 macro and "Could not open macro storage" | Mailmerge |