View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Extracting Text from Embedded Word Documents in Excel

Would not be more simple to enter the text into Excel and drop the Word
aspect ?
Unless you <really need the bells and whistles that a word processor
offers.

Anyway, this is by no means great, but works and should give you a starting
point. You can change to late binding late, once you have the Word code
figured out.

Private Sub CommandButton1_Click()
Dim WordDoc As OLEObject
Dim WordApp As Word.Application

Set WordDoc = ActiveSheet.OLEObjects(1)

With WordDoc
.Activate
Set WordApp = .Object.Application
End With

With WordApp
.ActiveDocument.Select
.Selection.wholestory
.Selection.Copy
.ActiveDocument.Close False
.Quit
End With

Range("A1").Select
ActiveSheet.PasteSpecial Format:="Unicode Text"

End Sub

NickHK

"Marc C" wrote in message
...
I have a report that uses embedded Word documents in Excel for a

technician
to write a narrative on a project in addition to his/her measurements that
are entered in Excel's cells. I am looking for an automated way to open

an
embedded Word document in the Excel report, extract the text from the Word
document, and paste it into a separate excel file. Is this possible?