Tengo el siguiente código que copy un área seleccionada de una hoja de datos de Excel y la pega en una diapositiva PTT. Quiero usar un código VBA para establecer la altura y el ancho del Objeto OLE pegado.
Este es el código que enfurecí hasta ahora:
Sub Copytopptonexsbusinesspro() Dim objPPT As Object Dim PPSlide As Slide Dim XLApp As Excel.Application Set objPPT = CreateObject("PowerPoint.Application") objPPT.Visible = True objPPT.Presentations.Open "H:\Commercie\Offerte, SLA & presentatie documenten\Offerte\Offerte\Offerte OneXS Business Pro.ppt" Sheets("OneXS Business Pro").Select Sheets("OneXS Business Pro").Unprotect ("harrie") Application.ScreenUpdating = False ' Reference existing instance of Excel Set XLApp = GetObject(, "Excel.Application") ' Copy the range XLApp.Range(Range("A5:L5", Range("A5:L5").End(xlToRight)), Range("A5:L5", Range("A5:L5").End(xlDown))).Rows.Copy Set PPSlide = objPPT.Presentations("H:\Commercie\Offerte, SLA & presentatie documenten\Offerte\Offerte\Offerte OneXS Business Pro.ppt").Slides(1) ' Paste the range PPSlide.Shapes.PasteSpecial DataType:=ppPasteOLEObject, Link:=msoFalse With .Shapes(.Shapes.Count) .Width = 150 .Height = 284.6 End With ' Clean up Set PPSlide = Nothing Set XLApp = Nothing Sheets("OneXS Business Pro").Select Application.ScreenUpdating = True Sheets("OneXS Business Pro").Protect ("harrie") End Sub
En esta línea me sale un error:
With .Shapes(.Shapes.Count) .Width = 150 .Height = 284.6
Mi pregunta: ¿qué hago mal en este código?
Saludos cordiales