View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
quartz[_2_] quartz[_2_] is offline
external usenet poster
 
Posts: 441
Default Display Word Paragraphs in Excel???

Dick,

Thanks so much, this is very helpful.

"Dick Kusleika" wrote:

quartz

A message box holds approximately 1024 characters. If your text is less
than that, you should be okay. Here's the basics of how to do it

Sub ShowParagraphs()

Dim wdApp As Word.Application
Dim wdDoc As Word.Document
Dim sPara As String
Dim sFileName As String
Dim i As Long

sFileName = "C:\Dick\Ng\01 Jan\Planning Services.doc"

Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Open(sFileName)

For i = 1 To 3
sPara = sPara & wdDoc.Paragraphs(i).Range.Text
Next i

wdDoc.Close False
wdApp.Quit

MsgBox sPara

End Sub

This is by no means instant, or even fast. You can make it faster, however,
depending on how many times it will run and some other factors.

--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com

quartz wrote:
There are multiple Word documents that get updated. I need a method
to allow a user to instantly (or as quickly as possible) display the
first 3 paragraphs from any particular Word document in Excel.

For example, in Excel user clicks "Planning Services"; then the first
3 paragraphs in the Word document "Planning Services.doc" is
displayed for the user. The user only needs to read the info, not do
anything else with it.

The paragraphs are relatively short, but I'm not sure they would fit
into a MsgBox. On the other hand, I would like to avoid the hassle of
developing a user form if possible. There will be many copies of the
Excel file distributed to many users on the network.

Any suggestions? Thanks much in advance.