Cannot use ppPasteOLEObject in PasteSpecial command in PowerPoint

G

Gail Hurn

I have the following VBA code that works in PowerPoint 2003. However, it
causes PowerPoint 2007 to crash. If I change the data type parameter in the
PasteSpecial command to ppPasteBitmap than it works in PowerPoint 2007.

Dim excelApp As Excel.Application
Dim workbooks As Excel.workbooks
Dim workbook As Excel.workbook
Dim worksheet As Excel.worksheet
Dim cell, cell2, copyRange As Excel.Range
Dim shapes As shapes
Dim Slide As Slide
Dim shape As ShapeRange

Set excelApp = CreateObject("Excel.Application")
Set workbook = excelApp.workbooks.Add
Set worksheet = workbook.Worksheets(1)
Set cell = worksheet.Range("A1")
cell.Value2 = "Region"
Set cell2 = worksheet.Range("A2")
cell.Value2 = "North"

Set copyRange = worksheet.Range("A1", "A2")
copyRange.Copy

Set Slide = ActivePresentation.Slides(2)
Slide.Select

Set shape = Slide.shapes.PasteSpecial(ppPasteOLEObject,
MsoTriState.msoFalse, "", 0, "", msoFalse)

workbook.Close False
 

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

Top