View Single Post
 
Old 08-17-2020, 08:36 AM
grumblid grumblid is offline Windows 7 64bit Office 2003
Novice
 
Join Date: Jul 2016
Posts: 23
grumblid is on a distinguished road
Default Would these macros be possible to make?

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
You'll notice when you use it, the vertical spaces between each of the sentences/paragraphs in the new document aren't clickable. Meaning if you want to have them work normally you have to Clear Formatting, which makes them all clump together, and then you have to go create normal spaces manually by pressing Enter at the start of each sentence/paragraph.

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 :]
Reply With Quote