Sub test_PasteOLEObjectIntoSheet()
PasteOLEObjectContentIntoSheet "oDoc", "Sheet2"
End Sub
'Set Reference to Microsoft Word xx.x Object Library
Sub PasteOLEObjectContentIntoSheet(sOLE As String, sSheet As String)
Dim wdApp As Word.Application
Dim myDoc As Word.Document
Dim wdstory As Word.Range
Dim oOLE As OLEObject
Set oOLE = ActiveSheet.OLEObjects(sOLE)
'MsgBox oOLE.OLEType 'Linked or not.
oOLE.Verb xlPrimary
Set wdApp = GetObject(, "Word.Application")
'wdApp.Visible = True
wdApp.Visible = False 'OLEObect will show briefly even with this setting.
Set myDoc = wdApp.ActiveDocument
Do
Loop Until Not myDoc Is Nothing
' MsgBox myDoc.Name
Set wdstory = myDoc.Content
'Same as that above
'Set wdstory = myDoc.StoryRanges(wdMainTextStory)
With wdstory.Font
.Name = "Arial"
.ColorIndex = wdRed
.Size = 16
End With
With Excel.ThisWorkbook.Worksheets(sSheet)
.UsedRange.Clear
'Setting the value like this does not include attributes.
.Range("A1").Value = myDoc.Content
myDoc.Range(myDoc.Content.Start, myDoc.Content.End).Copy
Excel.Worksheets(sSheet).Range("A2").PasteSpecial
'Another method to paste.
'ThisWorkbook.Worksheets(sSheet).Activate
'Excel.ActiveSheet.Paste
'ActiveSheet.Paste
Application.CutCopyMode = False
End With
myDoc.Close
wdApp.Quit
Set wdApp = Nothing
Set myDoc = Nothing
Set wdstory = Nothing
End Sub