Copy text from embedded Word object?

C

c mateland

In a worksheet is an embedded Word object. When I click a button, I
want the object's text to copy to cell A1. Can anyone please help me
with this?

I'm using Excel 2003.

Thanks,
Chuck
 
J

Joel

Sub Macro1()
'

For Each obj In ActiveSheet.OLEObjects
If InStr(obj.progID, "Word.Document") > 0 Then
'open word document
obj.Activate

Set WordDoc = obj.Object.Application.ActiveDocument
Set WordApp = obj.Application


pos = WordDoc.words.first.Start
pos2 = WordDoc.words.last.End
Set WordRange = WordDoc.Range(Start:=pos, End:=pos2)
WordText = WordRange.Text

ThisWorkbook.ActiveSheet.Range("A1") = WordText

Exit For
End If

Next obj



End Sub
 

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

Top