Extracting text from embedded Word Object

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

Guest

We have an embedded word object within our workbook and would like to
programmatically extract the text within the object and paste it in a
predefined text box. How would we go about doing this?

Thanks
 
Hi Barb,

like this:

Sub Test10000()

Dim oWrd As Word.Application
Dim rTmp As Word.Range
Dim s As String
Dim oWrk As Workbook
Dim oSht As Worksheet
Set oWrk = ActiveWorkbook
Set oSht = ActiveSheet
oSht.OLEObjects(1).Activate
Set oWrd = GetObject(, "Word.application")
Set rTmp = oWrd.ActiveDocument.Range
s = rTmp.text
oWrd.ActiveDocument.Close
'oWrd.Quit
oSht.OLEObjects("TextBox1").Object.Value = s
End Sub

Don't try to paste a 100 pages word doc with pictures! ;-)

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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