ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Extracting Text from Embedded Word Documents in Excel (https://www.excelbanter.com/excel-programming/385770-extracting-text-embedded-word-documents-excel.html)

Marc C

Extracting Text from Embedded Word Documents in Excel
 
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?

NickHK

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?





All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com