![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
My goal: copy and paste the highlights within the selected regions to another doc file (see the picture below). This means that when I select the region and run my macro, I want only "group together as" to be the result I get.
My current macro: Sub CopyHighlightsSelectedToOtherDoc() Dim ThisDoc As Document Dim ThatDoc As Document Dim r As Range Set ThisDoc = ActiveDocument Set r = ActiveDocument.Range(Selection.Range.Start, Selection.Range.End) 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 Problem: I'm a newbie and just found the original code somewhere else and modified it a bit. But there will always be an error on the Range Selection part. In this case, is that possible to let the macro use the currently selected sections only not the whole document? Some posts said macro cannot do things like that. My current code always goes to the end of the document, which gives "group together as" and also "accomplish a task automatically". Additionally, how to make the macro to save the results in another fixed document? Let's say I want to save it in a file named "container.docx" on the desktop. I tried Set ThatDoc = C:\Users\apple\Desktop\container.docx, but that didn't work. How to solve this then? I really appreciate anyone who can provide some help. |
Tags |
highlighted-text |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Chart with Actuals and Goals for Multiple INTL Regions | Italiano329 | Excel | 4 | 01-22-2016 09:48 AM |
![]() |
webharvest | Outlook | 1 | 08-15-2015 01:55 AM |
![]() |
Evgeny | Project | 3 | 01-03-2013 06:45 AM |
![]() |
Joeb | Project | 3 | 06-25-2012 04:18 PM |
Save Current Slide as Picture | excelledsoftware | PowerPoint | 2 | 01-18-2012 02:42 PM |