John Carney
asked on
Positioning the selected object (a table) in Powerpoint 2010
I have a macro in Excel that copies a range and then pastes it into PPT as a table. At which point I want to position it. As it stands now Line 1 moves other shapes around but leaves the desired one alone.
Another way would be to rename the table and then reference it as the object to be positioned. You know, the equivalent of
How do I write it so that PPT understands it? Please let me know how to write it both ways if possible
Thanks!
John
With .Slides(2).Shapes(.Slides(2).Shapes.Count)
.Top = 74
.Left = 20
End With
What I want to do is take the actively selected table on Slide 2 (the one that was just pasted in) and position it as shown. One way to do it would the PPT equivalent of this code in Excel:With Selection
.Left = 40
.top = 70
End With
Another way would be to rename the table and then reference it as the object to be positioned. You know, the equivalent of
With ActiveSheet.Shapes("DarkFlightTable")
.Left = 40
.top = 70
End With
How do I write it so that PPT understands it? Please let me know how to write it both ways if possible
Thanks!
John
If the table (or any object aka shape) is selected, you can use this::
With ActiveWindow.Selection.ShapeRange(1)
.Left = 40
.Top = 70
End With
ASKER
I just discovered that if I set a breakpoint on "With ActiveWindow.Selection.Sha peRange(1) " and step through the code it works. Here's the full code. Do you see anything that could be causing that and what would be the fix?
John
Sub RangeToPresentation()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim objName As String
Set rng = Range([B1], [G13].End(xlUp))
rng.Copy
Set PPApp = GetObject(, "Powerpoint.Application")
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide
With PPPres
.Windows(1).Activate
.Windows(1).View.GotoSlide 2
.Application.CommandBars.ExecuteMso ("PasteSourceFormatting")
End With
With PPApp.ActiveWindow.Selection.ShapeRange(1)
.Left = 25
.top = 74
.Height = 192
End With
End Sub
Thanks,John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Jamie, thanks! you're making me look to my co-workers like I know what I'm doing :- )
John
John
pls try (if the name of the shape is right in PPT)
Open in new window
Regards