Sub CreateCompoundDocument()
Dim rg As range
Dim obj As OLEObject
Set rg = ThisWorkbook.Worksheets(1).Cells(2, 2)
Set obj = InsertObject(rg, "C:\testdoc.doc", False)
If Not obj Is Nothing Then
Debug.Print "Object inserted."
Else
Debug.Print "Sorry - the object could not be inserted."
End If
Set obj = Nothing
Set rg = Nothing
End Sub
Function InsertObject(rgTopLeft As range, sFile As String, bLink As Boolean) As OLEObject
Dim obj As OLEObject
On Error GoTo ErrHandler
Set obj = rgTopLeft.Parent.OLEObjects.add(FileName:=sFile, Link:=bLink)
obj.Top = rgTopLeft.Top
obj.Left = rgTopLeft.Left
Set InsertObject = obj
Exit Function
ErrHandler:
Debug.Print Err.Description
Set InsertObject = Nothing
End Function