Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Select, copy and past first sentence from each paragraph to adifferent document
I've spent way too many hours trying trying to figure out a method to pull first sentences from an open document.
Is there a macro out there that will select the first sentence from every paragraph in the document, and then copy/paste it into a new document? |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Select, copy and past first sentence from each paragraph to a different document
You need to loop all paragraphs in the document, extract the first sentence,
copy it, and paste into a new target document. -- Stefan Blom Microsoft Word MVP wrote in message ... I've spent way too many hours trying trying to figure out a method to pull first sentences from an open document. Is there a macro out there that will select the first sentence from every paragraph in the document, and then copy/paste it into a new document? |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Select, copy and past first sentence from each paragraph to adifferent document
On Monday, March 31, 2014 10:25:25 AM UTC-6, wrote:
I've spent way too many hours trying trying to figure out a method to pull first sentences from an open document. Is there a macro out there that will select the first sentence from every paragraph in the document, and then copy/paste it into a new document? Stefan, Yes, that is the correct workflow...is there a macro available that will do that? Or can you point me to where I can find the VBA code that would work for this? Thanks! |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Select, copy and past first sentence from each paragraph to a different document
The following code inserts the first sentence of each paragraph in the
active document into a new, blank document. (Each sentence is placed in a separate paragraph in the target document.) Sub testmacro() Dim i As Long Dim numpara As Long Dim newdoc As Document Dim currentdoc As Document Dim r As Range Set currentdoc = ActiveDocument Set newdoc = Documents.Add Set r = newdoc.Content.Duplicate numpara = currentdoc.Paragraphs.Count For i = 1 To numpara currentdoc.Paragraphs(i).Range.Sentences(1).Copy r.Collapse wdCollapseEnd r.Paste r.InsertParagraphAfter Next i End Sub The macro uses copy and paste and it can probably be improved, but it seems to do the job. -- Stefan Blom Microsoft Word MVP wrote in message ... On Monday, March 31, 2014 10:25:25 AM UTC-6, wrote: I've spent way too many hours trying trying to figure out a method to pull first sentences from an open document. Is there a macro out there that will select the first sentence from every paragraph in the document, and then copy/paste it into a new document? Stefan, Yes, that is the correct workflow...is there a macro available that will do that? Or can you point me to where I can find the VBA code that would work for this? Thanks! |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Select, copy and past first sentence from each paragraph to adifferent document
Stefan,
Thank You!! This works exactly as I needed. On Tuesday, April 1, 2014 4:54:06 PM UTC-6, Stefan Blom wrote: The following code inserts the first sentence of each paragraph in the active document into a new, blank document. (Each sentence is placed in a separate paragraph in the target document.) Sub testmacro() Dim i As Long Dim numpara As Long Dim newdoc As Document Dim currentdoc As Document Dim r As Range Set currentdoc = ActiveDocument Set newdoc = Documents.Add Set r = newdoc.Content.Duplicate numpara = currentdoc.Paragraphs.Count For i = 1 To numpara currentdoc.Paragraphs(i).Range.Sentences(1).Copy r.Collapse wdCollapseEnd r.Paste r.InsertParagraphAfter Next i End Sub The macro uses copy and paste and it can probably be improved, but it seems to do the job. -- Stefan Blom Microsoft Word MVP wrote in message ... On Monday, March 31, 2014 10:25:25 AM UTC-6, wrote: I've spent way too many hours trying trying to figure out a method to pull first sentences from an open document. Is there a macro out there that will select the first sentence from every paragraph in the document, and then copy/paste it into a new document? Stefan, Yes, that is the correct workflow...is there a macro available that will do that? Or can you point me to where I can find the VBA code that would work for this? Thanks! |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
Select, copy and past first sentence from each paragraph to a different document
I'm glad I could help!
-- Stefan Blom Microsoft Word MVP wrote in message ... Stefan, Thank You!! This works exactly as I needed. On Tuesday, April 1, 2014 4:54:06 PM UTC-6, Stefan Blom wrote: The following code inserts the first sentence of each paragraph in the active document into a new, blank document. (Each sentence is placed in a separate paragraph in the target document.) Sub testmacro() Dim i As Long Dim numpara As Long Dim newdoc As Document Dim currentdoc As Document Dim r As Range Set currentdoc = ActiveDocument Set newdoc = Documents.Add Set r = newdoc.Content.Duplicate numpara = currentdoc.Paragraphs.Count For i = 1 To numpara currentdoc.Paragraphs(i).Range.Sentences(1).Copy r.Collapse wdCollapseEnd r.Paste r.InsertParagraphAfter Next i End Sub The macro uses copy and paste and it can probably be improved, but it seems to do the job. -- Stefan Blom Microsoft Word MVP wrote in message ... On Monday, March 31, 2014 10:25:25 AM UTC-6, wrote: I've spent way too many hours trying trying to figure out a method to pull first sentences from an open document. Is there a macro out there that will select the first sentence from every paragraph in the document, and then copy/paste it into a new document? Stefan, Yes, that is the correct workflow...is there a macro available that will do that? Or can you point me to where I can find the VBA code that would work for this? Thanks! |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cannot copy and past paragraph marks - Word 2003 | Microsoft Word Help | |||
Select a sentence to go in First Paragraph | Microsoft Word Help | |||
Keystrokes to select current paragraph of Word document | Microsoft Word Help | |||
Does copy/past increase document size? | New Users | |||
When I select a paragraph and press "Bullet", all document become. | Microsoft Word Help |