![]() |
|
#1
|
|||
|
|||
|
Years ago someone here was kind enough to make a macro for me that asked for a word, then sent every instance of that word into a new document so I didn't have to go dig for each sentence/paragraph containing that word manually. It's worked wonders!
But as my workload has increased of late, I was wondering if it's possible to improve it in a certain way. Here's the macro so you can test it yourself and see what I'm talking about (I'm on MS Word 2003, by the way. Old computer but it still works, haha) 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.Paragraphs(1).Range.Delete
oRng.Collapse 0
Loop
End With
oDoc.Range.ParagraphFormat.SpaceBefore = 12
lbl_Exit:
Exit Sub
Is there a way to set this macro so the spaces in the new document are normal from the get-go? Also, would it be possible to make a macro that takes an entire document and re-arranges the sentences and paragraphs by length? So if you want all your big paragraphs to be at the top and all your shorter paragraphs/single sentences at the bottom, is that sort of thing possible? And if not a macro, is there an online tool that does that sort of thing, sort of like ones that alphabetize things for you? I hope that all made sense, and I'll be happy to clarify if it didn't. Thanks if anyone is able to help :] |
| Tags |
| help me, macros, ms word |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
How to automatically enable the macros upon opening a file with macros?
|
laurieli | Office | 7 | 01-17-2016 08:56 AM |
| Can you make templates dynamically update macros/etc. from Normal.DOT? | New Daddy | Word | 2 | 11-18-2013 09:07 AM |
VBA macros
|
tays01s | Word VBA | 6 | 08-03-2011 09:42 PM |
| Macros | nore | Outlook | 0 | 06-01-2011 04:39 PM |
Macros
|
Desertwrangler | Word VBA | 6 | 06-25-2010 07:06 AM |