Question : PowerPoint Crashes on PasteSpecial DataType:=ppPasteOLEObect

I am using VBA to copy the selected range in Excel into PowerPoint as an OLE object using PasteSpecial(ppPasteOLEObject).  However, PP crashes whenever I try to do this.  When I change the DataType for the PasteSpecial operation to "ppPasteMetafilePicture", for example, it works fine.  What is it about DataType:=ppPasteOLEObject that is causing PP to crash?

I am using Excel 2007 and the VBA code below is included in a standard module for an add-in.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
Public Sub ImportFromExcel()
    Dim i As Integer
    Dim shp As Shape
    Dim wb As Excel.Workbook
    Dim xlApp As Excel.Application  
    'Create Excel application object
    On Error Resume Next
    Set xlApp = GetObject(, "Excel.Application")
    If xlApp Is Nothing Then
        MsgBox "Excel must be open to import.", vbExclamation
        Exit Sub
    End If
    If TypeName(xlApp.Selection) = "Range" Then
        'Apply hidden defined name to selected Excel range
        xlApp.ActiveWorkbook.Names.Add name:="foo", RefersTo:=xlApp.Selection, Visible:=False
        'Import selected range into Powerpoint
        i = ActiveWindow.Selection.SlideRange.SlideIndex
        xlApp.Selection.Copy
        Set shp = ActivePresentation.Slides(i).Shapes.PasteSpecial(ppPasteOLEObject).Item(1) 'DOES NOT WORK!!!
'        Set shp = ActivePresentation.Slides(i).Shapes.PasteSpecial(ppPasteMetafilePicture) 'WORKS!!!
        With shp
'            do some stuff here...
        End With
    End If
End Sub

Answer : PowerPoint Crashes on PasteSpecial DataType:=ppPasteOLEObect

Conclusion:  PasteSpecial in PowerPoint is buggy.
Random Solutions  
 
programming4us programming4us