View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JulieD JulieD is offline
external usenet poster
 
Posts: 618
Default How to select the first 5 paragraphs in a Word Document from Excel

Hi

this seems to work

Sub testword()
Dim wdApp As Word.Application
Set wdApp = New Word.Application
argFullname = "C:\test.doc"
wdApp.documents.Open Filename:=argFullname, ReadOnly:=argReadOnly
wdApp.Selection.HomeKey Unit:=wdStory
wdApp.Selection.MoveDown Unit:=wdParagraph, Count:=5, Extend:=wdExtend
wdApp.Selection.Copy
wdApp.documents(argFullname).Close SaveChanges:=False
wdApp.Application.Quit
Set wdApp = Nothing

ThisWorkbook.Activate
Sheets("Sheet4").Activate
Range("A1").Select
ActiveSheet.Paste
Msgbox "Done"
End Sub


Hope this helps
Cheers
JulieD

"quartz" wrote in message
...
Does anyone know how to select the first 5 paragraphs in a Word document
from
Excel?

I can get a ref and open the document. Now I need to select the first 5
paragraphs and copy them to the clipboard. My code so far looks like this:

Dim wdApp As Word.Application
Set wdApp = New Word.Application
wdApp.Documents.Open Filename:=argFullName, ReadOnly:=argReadOnly
<<<code to select first 5 paragraphs needed here
<<<code to copy needed here
wdApp.Documents(FileName).Close SaveChanges:=False
wdApp.Application.Quit
Set wdApp = Nothing

Thanks in advance.