View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Word Document Object on excel Sheet

Sub test()
Dim rngDest As Range
Dim ole As OLEObject
Dim objDoc As Object ' Word.Document
Dim objWdRange As Object ' Word.Range

Set ole = Worksheets("Sheet1").OLEObjects(1) '

Set objDoc = ole.Object
' above failed for me once until once activating
' & deactivating the embedded object.
' then it always worked whatever the selection
' might need to look into that more

If TypeName(objDoc) = "Document" Then
Set objWdRange = objDoc.Content
objWdRange.Copy

' only to set the paste range to the former
' activecell on the destination sheet
Set rngDest = Worksheets("Sheet2").Range("A1")
rngDest.Parent.Activate
rngDest.Activate

rngDest.Parent.Paste ' paste to a worksheet object
End If

End Sub

You could, if you need to, get a lot more information about Paragraphs,
Sentences, Words etc before deciding what you want to copy

Regards,
Peter T

"K" wrote in message
...
Hi Peter, Thanks for replying. Your macro pretty much doing what i
need. Just another question that in Word Document Object which i have
on my excel sheet i have some coloured text and some text is in bold
and some text is in normal. How can i get same formated text on my
excel sheet. At the moment i getting result on a message box but it
would be greate if i get result on sheet and also in same format as it
appeares in word document object. Please help