![]() |
|
#18
|
||||
|
||||
|
The following macro will copy each paragraph in the current document, that contains the word or phrase entered, to a new document. http://www.gmayor.com/installing_macro.htm
Code:
Sub GetParas()
Dim oDoc As Document
Dim oRng As Range
Dim strKeyWord As String
strKeyWord = InputBox("Enter the word to find")
If strKeyWord = "" Then GoTo lbl_Exit
Set oRng = ActiveDocument.Range
Set oDoc = Documents.Add
With oRng.Find
Do While .Execute(FindText:=strKeyWord, _
MatchCase:=False, _
MatchWholeWord:=True)
oDoc.Range.InsertAfter oRng.Paragraphs(1).Range.FormattedText
oRng.Collapse 0
Loop
End With
lbl_Exit:
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
| Tags |
| bodies, ctrl+f, text |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Outlook 2007 not downloading message bodies automatically | Mr Davo | Outlook | 3 | 02-09-2014 09:23 PM |
| Scrolling text for entire presentation | rtully87 | PowerPoint | 0 | 11-07-2013 09:28 AM |
| Continuous scrolling text for entire presentation | rtully87 | PowerPoint | 0 | 10-25-2013 08:37 AM |
| Editing Text through your entire presentation macVSpc | PowerPointSD | PowerPoint | 1 | 12-06-2012 08:42 AM |
| Moving Entire Text | Sleeper | Word | 2 | 01-10-2010 04:40 PM |