Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2013, 01:37 PM
MSoffice1 MSoffice1 is offline Copy paste highlighted text to another doc Windows 7 32bit Copy paste highlighted text to another doc Office 2010 32bit
Novice
Copy paste highlighted text to another doc
 
Join Date: Feb 2013
Posts: 6
MSoffice1 is on a distinguished road
Default Copy paste highlighted text to another doc

I am trying find/build a macro that can copy all my highlighted text in a word document and paste it to another document. Is this possible?
Reply With Quote
  #2  
Old 02-10-2013, 02:42 PM
OTPM OTPM is offline Copy paste highlighted text to another doc Windows 7 32bit Copy paste highlighted text to another doc Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi
Are you looking to copy your highlighted text to a new blank document or an existing document?
If it is an existing document is to a specific location in that document?
Tony
Reply With Quote
  #3  
Old 02-10-2013, 02:53 PM
MSoffice1 MSoffice1 is offline Copy paste highlighted text to another doc Windows 7 32bit Copy paste highlighted text to another doc Office 2010 32bit
Novice
Copy paste highlighted text to another doc
 
Join Date: Feb 2013
Posts: 6
MSoffice1 is on a distinguished road
Default

Hi Tony,

It will be posted to a new blank doc.
Reply With Quote
  #4  
Old 02-10-2013, 04:14 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

And by "highlighted", do you mean that you have selected text (highlighted); or do you mean non-selected text that has highlights
Reply With Quote
  #5  
Old 02-10-2013, 04:18 PM
MSoffice1 MSoffice1 is offline Copy paste highlighted text to another doc Windows 7 32bit Copy paste highlighted text to another doc Office 2010 32bit
Novice
Copy paste highlighted text to another doc
 
Join Date: Feb 2013
Posts: 6
MSoffice1 is on a distinguished road
Default

The highlighted sentences are from using the yellow Highlighter feature from the menu on the homepage. It has a highlighter pen look to it.
Reply With Quote
  #6  
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
  #7  
Old 02-11-2013, 02:28 AM
macropod's Avatar
macropod macropod is offline Copy paste highlighted text to another doc Windows 7 64bit Copy paste highlighted text to another doc Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted (and solved only 20 minutes after the last post by MSOffice1) at: http://www.excelforum.com/word-progr...html?p=3119500
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 02-11-2013, 06:33 AM
MSoffice1 MSoffice1 is offline Copy paste highlighted text to another doc Windows 7 32bit Copy paste highlighted text to another doc Office 2010 32bit
Novice
Copy paste highlighted text to another doc
 
Join Date: Feb 2013
Posts: 6
MSoffice1 is on a distinguished road
Default

Thanks Fumei. I cant tell you how much I appreciate it : )
Reply With Quote
  #9  
Old 02-14-2013, 10:00 AM
MSoffice1 MSoffice1 is offline Copy paste highlighted text to another doc Windows 7 32bit Copy paste highlighted text to another doc Office 2010 32bit
Novice
Copy paste highlighted text to another doc
 
Join Date: Feb 2013
Posts: 6
MSoffice1 is on a distinguished road
Default

Hello awesome Forums,
Obviously you can tell that I am new to this..ie this is my first post!

The reason I posted the question on this forum is b/c my question is related to MS Word and not MS Excel. I thought the other site was primary for Excel questions (hence the forum name) and would not receive an accurate response or any response at all...ie 2 different program sites. What I should of done was delete the question on the other site. Sorry for the confusion and I hope you understand. Have a great end of the week and weekend

Thx
Reply With Quote
  #10  
Old 07-18-2013, 10:35 AM
MSoffice1 MSoffice1 is offline Copy paste highlighted text to another doc Windows 7 32bit Copy paste highlighted text to another doc Office 2010 32bit
Novice
Copy paste highlighted text to another doc
 
Join Date: Feb 2013
Posts: 6
MSoffice1 is on a distinguished road
Default

Fumei,

Thank you again for the code you provided. Can you tweak this where it will copy and past rather than cut and paste to the other doc.

Thanks
Reply With Quote
  #11  
Old 09-16-2019, 02:30 AM
MaheshT MaheshT is offline Copy paste highlighted text to another doc Windows XP Copy paste highlighted text to another doc Office 2016
Novice
 
Join Date: Sep 2019
Posts: 1
MaheshT is on a distinguished road
Default

How can I add page number and section heading of the highlighted para along with highlighted para
Reply With Quote
  #12  
Old 07-14-2021, 12:58 AM
Jakov93 Jakov93 is offline Copy paste highlighted text to another doc Windows 10 Copy paste highlighted text to another doc Office 2010
Advanced Beginner
 
Join Date: Jul 2021
Posts: 42
Jakov93 is on a distinguished road
Default

Quote:
Originally Posted by fumei View Post
And by "highlighted", do you mean that you have selected text (highlighted); or do you mean non-selected text that has highlights
Mr. fumei, What if I have a range of the document, and this range may include text, pictures, tables... etc

So, I want to select the range and then copy it with the same formatting to a new document.

I will appreciate your help by making such a VBA code to do my need.
Thanks in advance
Reply With Quote
  #13  
Old 04-10-2022, 09:43 AM
burniksapwet burniksapwet is offline Copy paste highlighted text to another doc Windows 10 Copy paste highlighted text to another doc Office 2007
Novice
 
Join Date: Jan 2022
Posts: 6
burniksapwet is on a distinguished road
Default

Quote:
Originally Posted by fumei View Post
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.

This is awesome. But I was wondering if you can tweak this for my need. Basically it does the same thing but instead of pasting it in a new document I want it to override the current document. I want nothing else on that document but for the result to be pasted, then save it. This is so that I can keep the result under the same filename.
Thank you.
Reply With Quote
  #14  
Old 04-10-2022, 03:52 PM
macropod's Avatar
macropod macropod is offline Copy paste highlighted text to another doc Windows 10 Copy paste highlighted text to another doc Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You don't need a macro for that - simply:
• Format all content as hidden text
• Use Find/Replace to find and unhide all highlighted text
• Copy everything and paste it as unformatted text.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 04-15-2022, 12:52 PM
burniksapwet burniksapwet is offline Copy paste highlighted text to another doc Windows 10 Copy paste highlighted text to another doc Office 2007
Novice
 
Join Date: Jan 2022
Posts: 6
burniksapwet is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
You don't need a macro for that - simply:
• Format all content as hidden text
• Use Find/Replace to find and unhide all highlighted text
• Copy everything and paste it as unformatted text.
I need it to be in a macro because the next step is creating a .bat for it that will automate doing it for multiple documents inside a folder. Thank you.
Reply With Quote
Reply

Thread Tools
Display Modes


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 04:03 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