Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] actnt8528@gmail.com is offline
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom[_3_] Stefan Blom[_3_] is offline
external usenet poster
 
Posts: 6,897
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] actnt8528@gmail.com is offline
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom[_3_] Stefan Blom[_3_] is offline
external usenet poster
 
Posts: 6,897
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
[email protected] actnt8528@gmail.com is offline
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom[_3_] Stefan Blom[_3_] is offline
external usenet poster
 
Posts: 6,897
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot copy and past paragraph marks - Word 2003 Dianna Microsoft Word Help 2 September 6th 07 12:29 AM
Select a sentence to go in First Paragraph Marilyn Microsoft Word Help 3 August 23rd 07 04:42 AM
Keystrokes to select current paragraph of Word document Kitten Microsoft Word Help 1 April 20th 07 10:20 AM
Does copy/past increase document size? Jeff New Users 5 August 27th 06 12:26 PM
When I select a paragraph and press "Bullet", all document become. Roni Microsoft Word Help 1 February 15th 05 02:31 PM


All times are GMT +1. The time now is 03:51 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"