PDA

View Full Version : Setting lockaspectratio to false permanently fo linked excel table in PowerPoint 2007



Ambichamti
07-29-2020, 12:29 PM
In this code if I use link as true
And set shapes height to slideheight and then width it expands even more even though I set lockaspectratio to false.
If I don't use link as true it works fine

Option Explicit

Sub PowerPointLibrary()

Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppSlide As PowerPoint.Slide

Set ppApp = New PowerPoint.Application

ppApp.Visible = True
ppApp.Activate

Set ppPres = ppApp.Presentations.Add

Set ppSlide = ppPres.Slides.Add(1, ppLayoutTitle)
ppSlide.Select

ppSlide.Shapes(1).TextFrame.TextRange.Text = "HOLLYWOOD"
ppSlide.Shapes(2).TextFrame.TextRange.Text = "Top Movies Of All Time"

ppSlide.Shapes(1).TextFrame.TextRange.Font.Size = 30
ppSlide.Shapes(1).TextFrame.TextRange.Font.Color = vbRed

ppSlide.Shapes(2).TextFrame.TextRange.Font.Size = 20
ppSlide.Shapes(2).TextFrame.TextRange.Font.Color = rgbDarkBlue

Set ppSlide = ppPres.Slides.Add(2, ppLayoutBlank)
ppSlide.Select

Sheet1.Activate

Range("A1").CurrentRegion.Select
Range("A1").CurrentRegion.Copy
ppApp.ActiveWindow.View.PasteSpecial ppPasteOLEObject, , , , , True
ppSlide.Shapes(1).Select
ppSlide.Shapes(1).LockAspectRatio = False
ppSlide.Shapes(1).Width = ppPres.PageSetup.SlideWidth
ppSlide.Shapes(1).Height = ppPres.PageSetup.SlideHeight
ppSlide.Shapes(1).Left = 0
ppSlide.Shapes(1).Top = 0

Set ppSlide = ppPres.Slides.Add(3, ppLayoutBlank)
ppSlide.Select

Chart4.Select
Chart4.ChartArea.Copy
ppSlide.Shapes.PasteSpecial
ppSlide.Shapes(1).LockAspectRatio = False
ppSlide.Shapes(1).Width = ppPres.PageSetup.SlideWidth
ppSlide.Shapes(1).Height = ppPres.PageSetup.SlideHeight
ppSlide.Shapes(1).Left = 0
ppSlide.Shapes(1).Top = 0


Set ppPres = Nothing
Set ppApp = Nothing
End Sub

Please help
Whether pasted link to be referred as oleobject or something. please provide some valid modified code so that lockaspectratio set to false for linked object

For me problem is while pasting linked object(either table range or chart) from excel to PowerPoint 2007. No problem pasting and lockaspectratio in PowerPoint higher version. No problem pasting picture or shape that is not linked. Another thing what I noticed that only problem is setting lockaspectratio from format tab size group dialog, else if I right click linked object and set lockaspectratio by going to format object it actually works. Currently I don't know what is difference between those two methods and I can't set lockaspectratio to false permanently. Once I set it to false it works for very next step that is changing width or height but then it automatically sets to true. Please provide code that actually sets lockaspectratio to linked objects in PowerPoint 2007.