Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 02-10-2013, 11:18 PM
fumei fumei is offline Copy paste highlighted text to another doc Windows 7 64bit Copy paste highlighted text to another doc Office XP
Expert
 
Join Date: Jan 2013
Posts: 440
fumei is on a distinguished road
Default

Code:
Sub CopyHighlightsToOtherDoc()
Dim ThisDoc As Document
Dim ThatDoc As Document
Dim r As Range
Set ThisDoc = ActiveDocument
Set r = ThisDoc.Range
Set ThatDoc = Documents.Add
With r.Find
   .Text = ""
   .Highlight = True
   Do While .Execute(Forward:=True) = True
      ThatDoc.Range.InsertAfter r.Text & vbCrLf
      r.Collapse 0
   Loop
End With
End Sub

All highlighted text in the ActiveDocument are copied (with an added paragraph mark to separate them) to a new document.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Text Twice to Paste into word Albundy Word 2 09-02-2016 12:59 PM
Copy paste highlighted text to another doc Find & selected paras with highlighted text & copy to clipboard marceepoo Word VBA 1 09-14-2012 08:20 PM
Copy paste highlighted text to another doc Table copy/paste suddenly text-only mjcoon Word Tables 20 04-28-2012 08:53 PM
Can't copy/cut and paste text in Word 2002 mmiller751 Word 0 04-17-2012 02:55 PM
Losing Text box data when copy and paste Spay Excel 0 03-15-2011 07:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:10 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