Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 08-02-2016, 08:07 PM
Guessed's Avatar
Guessed Guessed is offline Ctrl+F entire bodies of text? Windows 10 Ctrl+F entire bodies of text? Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,995
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

AFAIK discontinuous selections is not scriptable by Word VBA. But you could create code to extract all those paragraphs and/or transfer them somewhere else.

You need to explain the whole task if you want proper coding suggestions.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #17  
Old 08-02-2016, 08:36 PM
grumblid grumblid is offline Ctrl+F entire bodies of text? Windows 7 64bit Ctrl+F entire bodies of text? Office 2003
Novice
Ctrl+F entire bodies of text?
 
Join Date: Jul 2016
Posts: 23
grumblid is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
AFAIK discontinuous selections is not scriptable by Word VBA. But you could create code to extract all those paragraphs and/or transfer them somewhere else.

You need to explain the whole task if you want proper coding suggestions.
I don't know how Word VBA works or how to make a macro, but I'll try to explain the task I have in mind.

Basically I'd have one MS Word document with lots of paragraphs, I'd use a macro like the one you made to get all the paragraphs that have a certain word, then I'd transfer them to a blank (or already saved) MS Word document so they're all together.

Or, a way to have them all moved to the bottom of the first document all at once. That way it's just a one click-and-drag away from getting them all selected together for a cut and paste onto the second document, instead of multiple times just to get everything where I want it.

The thing that always slowed me down is the 'unselected' paragraphs between the selected ones getting in the way of cutting and pasting more at a time. I deal with a LOT of paragraphs covering many different subjects, and sometimes they're so scattered that I'm cutting and pasting one paragraph at a time. So the prospect of ways to make the process even slightly faster interests me a lot~

Thank you for being patient with me and my less than simple problem :]
Reply With Quote
  #18  
Old 08-02-2016, 08:56 PM
gmayor's Avatar
gmayor gmayor is offline Ctrl+F entire bodies of text? Windows 10 Ctrl+F entire bodies of text? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #19  
Old 08-03-2016, 05:32 AM
grumblid grumblid is offline Ctrl+F entire bodies of text? Windows 7 64bit Ctrl+F entire bodies of text? Office 2003
Novice
Ctrl+F entire bodies of text?
 
Join Date: Jul 2016
Posts: 23
grumblid is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
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
This is another really good one! Thank you for taking the time :]

I was curious if we could iron out some things with this one. Just a few things that leave it wanting:

1.) Would it be possible to make so the macro functions as a cut-and-paste rather than a copy-and-paste? It's essential for reducing the page amount of the first document being cut-and-pasted from

2.) I noticed the new document has copies of certain paragraphs that used the key word more than once. So a paragraph that said 'game' three times, the new document the macro made has three copies of that paragraph next to each other.

3.) This one isn't so bad, but is it possible to make the new document have spaces between the paragraphs? They all got placed directly beneath one another instead of having gaps between them, as if it's all one giant super-wall of text ^ ^'

I appreciate your help thus far whether we can do this or not :]

Last edited by grumblid; 08-03-2016 at 04:23 PM.
Reply With Quote
  #20  
Old 08-03-2016, 06:58 PM
Guessed's Avatar
Guessed Guessed is offline Ctrl+F entire bodies of text? Windows 10 Ctrl+F entire bodies of text? Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,995
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Modifying Graham's superior method to do that would be
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
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #21  
Old 08-04-2016, 04:55 AM
grumblid grumblid is offline Ctrl+F entire bodies of text? Windows 7 64bit Ctrl+F entire bodies of text? Office 2003
Novice
Ctrl+F entire bodies of text?
 
Join Date: Jul 2016
Posts: 23
grumblid is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
Modifying Graham's superior method to do that would be
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
End Sub
Perfect. This does exactly what I need it to! owo

Thank you so much, everyone. I'll get out of your hair now, though if I have problems in the future, I'll know where to go :]
Reply With Quote
Reply

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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:30 PM.


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