Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-06-2017, 07:47 PM
gmaxey gmaxey is offline Macro for copying text between two Words. Windows 7 32bit Macro for copying text between two Words. Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Sub FindTextBetweenWords()
Dim oRng As Word.Range, oPasteRng As Range
Dim oDoc As Document, oTargetDoc As Document
  Set oDoc = ActiveDocument
  Set oTargetDoc = Documents.Add
  oDoc.Activate
  Set oRng = oDoc.Range
  With oRng.Find
    .ClearFormatting
    .Wrap = wdFindStop
    .MatchCase = False
    .Text = "References:*Working paper No"
    .MatchWildcards = True
    While .Execute
       oRng.Select
       Selection.EndKey Unit:=wdLine, Extend:=wdExtend
       Selection.Copy
       Set oPasteRng = oTargetDoc.Range
       oPasteRng.Collapse wdCollapseEnd
       oPasteRng.Paste
       oRng.Collapse wdCollapseEnd
    Wend
  End With
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro for copying text between two Words. Copying Certain Text From Numerous Cells using Macro Sean_Needs_Help Excel 3 11-08-2016 04:39 PM
Extracting multiple words from one cell into individual rows while copying all other data randyaserve Excel Programming 4 10-05-2015 09:52 AM
Copying words without initial word space bertietheblue Word 2 11-03-2013 04:46 PM
Macro for copying text between two Words. Macro for Copying Charts to Powerpoint bremen22 Excel Programming 1 10-01-2013 03:27 PM
Macro for replacing, copying and undoing. vthomeschoolmom Word VBA 1 12-05-2012 07:41 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:39 AM.


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