PDA

View Full Version : PASTE AND POSITION EXCEL LINKS IN POWERPOINT



slevitt5
08-06-2013, 04:48 PM
Hi all,

I am working on a project that requires copying and pasting charts from Excel into PowerPoint using "Paste Special" > "Paste Link" > "Microsoft Excel Worksheet (code) Object." Not only am I trying to avoid having to go through all three of those steps, but I would like all the pasted chart links to be positioned in the bottom left corner of each slide. I started working on a Macro within PowerPoint, but since I am a beginner, I have hit a wall and would love some help.

Here is what I have:

Sub Bottom_Left_Paste()

Dim oSh As Shape

Set oSh = ActivePresentation.Slides(1).Shapes.PasteSpecial(DataType:=ppPasteOLEObject , Link:=True)

With oSh
.Left = 0
.Top = 367
End With

End Sub

Having already copied the specific cells on Excel to my clipboard, after using this macro, it succesfully posts the chart as a link on slide #1, but posts in the middle of the slide (not the bottom left corner). However, an error message also pops up saying "Run-Time Error '13' - Type mismatch."

I would like to be able to paste the cells from Excel into Powerpoint as a link (like above), but I want to post to the current slide I am on (not slide #1) and I would like it to paste automatically in the bottom left corner.

Thanks in advance!

John Wilson
08-07-2013, 11:07 AM
When you paste PowerPoint does NOT return a SHAPE it returns a SHAPERANGE (you shoud be seeing an error?)
The shape to move is ShapeRange(1)
You can paste to the current slide as below (make sure a slide is selected)

To determine the bottom left look at the slide height - the shape height

Sub Bottom_Left_Paste()
Dim oShR As ShapeRange
Dim osld as Slide
Set osld=ActiveWindow.Selection.SlideRange(1)
Set oShR = osld.Shapes.PasteSpecial(DataType:=ppPasteOLEObject, Link:=True)
With oShR(1)
.Left = 0
.Top = ActivePresentation.PageSetup.SlideHeight - oShR(1).Height
End With
End Sub