Log in

View Full Version : [SLEEPER:] Shape sizing problems



mantooth29
07-11-2012, 12:57 PM
I am having trouble with sizing pasted objects inside power point.
My code copies two excels ranges and pastes them into power point.
I have two problems

1) Sizing the objects is ALL OVER THE PLACE. If I change the width on Object 3 from 190 to 200, the shape goes from smaller than half the slide to well outside the borders. If I change the width from 100 to 150, there is almost no change. Also, changing the Height still affects the width greatly.
This makes me think that LockAspectRatio=msoFalse is not working.
Also, I am not sure but I think having multiple shapes to resize is interfering as well.

2) How can I do a regular paste instead of paste special. It always causes an error when I attempt to do that.



Sub PptProblems()
Dim pptApp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSlide As PowerPoint.Slide
Dim pptShape As PowerPoint.Shape
Dim ind_CY As Excel.Range, tbl_ind_CY
Set ind_CY = Sheets("PC Summary").Range("ind_CY")
Set tbl_ind_CY = Sheets("PC Summary").Range("tbl_ind_CY")
Set pptApp = New PowerPoint.Application
RangeLink = True
pptApp.Presentations.Add
pptApp.Visible = msoTrue
pptApp.ActivePresentation.Slides.Add 1, ppLayoutBlank
ThisWorkbook.Worksheets("PC Summary").Activate
ind_CY.Copy
pptApp.ActivePresentation.Slides(1).Shapes.PasteSpecial(ppPasteShape, link:=RangeLink).Select
ThisWorkbook.Worksheets("PC Summary").Activate
tbl_ind_CY.Copy ' copy an Excel range
pptApp.ActivePresentation.Slides(1).Shapes.PasteSpecial(ppPasteShape, link:=RangeLink).Select 'Special ppPasteEnhancedMetafile
With pptApp.ActivePresentation.Slides(1).Shapes("Object 2")
.LockAspectRatio = msoFalse
.Left = 8
.Top = 2
.Width = 200
.Height = 35
End With
With pptApp.ActivePresentation.Slides(1).Shapes("Object 3")
.LockAspectRatio = msoFalse
.Left = 0
.Top = 50
.Width = 200
.Height = 140
End With
RangeLink = False
End Sub



I am pretty good at programming in Excel, but PowerPoint remains elusive. And I was thinking it would be easier!

John Wilson
07-12-2012, 12:33 AM
Without seeing your excel it's not easy to say what is being pasted. If you are opasting a link then it will be an excel object and lockaspectratio will not apply - it is always true.