Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-17-2020, 08:36 AM
grumblid grumblid is offline Would these macros be possible to make? Windows 7 64bit Would these macros be possible to make? Office 2003
Novice
Would these macros be possible to make?
 
Join Date: Jul 2016
Posts: 25
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
 

Tags
help me, macros, ms word

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Would these macros be possible to make? 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
Would these macros be possible to make? VBA macros tays01s Word VBA 6 08-03-2011 09:42 PM
Macros nore Outlook 0 06-01-2011 04:39 PM
Would these macros be possible to make? Macros Desertwrangler Word VBA 6 06-25-2010 07:06 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:32 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft