Extracting Text from Embedded Word Documents in Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top