3

Code that perfectly works in earlier versions of PPT stopped working in 2016. When I try to change the left property of a shape in a chart, I get a Method left of object shape failed error. I can perfectly read the .Left property.

I am running out of ideas? What can I do?

Sub test11()
  Dim sld As Slide
  Dim objChart As Object
  Dim shpBubble As Object
  Set sld = ActivePresentation.Slides("ScatterPlot01_Purch6")
  Set objChart = sld.Shapes("Chart01").Chart
  sld.Select
  objChart.Select

  Set shpBubble = objChart.Shapes("P01")
  'shpBubble.Select

  Debug.Print shpBubble.Left, shpBubble.Visible
  shpBubble.Left = 10
End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Edwin Ederle
  • 71
  • 1
  • 5

1 Answers1

2

UPDATE

Having tested in PowerPoint 2010 and 2013, where it works, this now looks like a bug in 2016!

* END *

I managed to recreate the error in PowerPoint 2016 (PC) by manually adding a shape to a test chart (select the chart then click Format / Insert Shapes) and trying to write to several of it's properties including position and formatting such as changing fill colour. All generate an error.

Maybe one workaround is to use the .Delete method to delete the desired shape and then add a new shape at the required size and position. Something like this:

Sub test11()
  Dim sld As Slide
  Dim objChart As Chart 'Object
  Dim shpBubble As Shape 'Object
  Set sld = ActivePresentation.Slides("ScatterPlot01_Purch6")
  Set objChart = sld.Shapes("Chart01").Chart
  sld.Select
  objChart.Select ' this won't work as you can only select the parent shape sld.Shapes("Chart01")

  With objChart
    .Shapes("P01").Delete
    .Shapes.AddShape msoShapeOval, 10, 10, 20, 20
  End With
End Sub

The challenge is that because the new shape is added as read only, the formatting can't be set!

Jamie Garroch - MVP
  • 2,839
  • 2
  • 16
  • 24
  • 1
    The weird thing. It worked on PPT 2013 and it is not read-only, I can change the visible property as well as changing the text shpBubble.TextFrame.TextRange.Text = "X" Only changing the position (top, left, ..) gives me that error – Edwin Ederle Jan 25 '17 at 15:19
  • I updated my answer accordingly. Looks like a bug and I've forwarded to a PowerPoint MVP expert in the VBA field to confirm. – Jamie Garroch - MVP Jan 25 '17 at 17:02
  • 1
    I've verified that the problem appears in several releases of PPT 2016 but not in my copy of 2013. I've forwarded a simplified description of the problem to several acquaintances on the PPT team at MS. I don't think that there's any question about it: you've unearthed a bug, @EdwinEderle – Steve Rindsberg Jan 25 '17 at 18:48
  • A silly question: Can I hope that the PPT team at MS might give a workaround on short notice? – Edwin Ederle Jan 25 '17 at 20:08
  • We may all *hope* whatever we choose to. ;-) Whether MS acts on our hopes and dreams ... another story. As I understand it, though, they do give higher priority to regression bugs like this. Fixes get released to O365 (ie subscription) users fairly quickly. It may take longer before non-subscription versions get the fix. – Steve Rindsberg Jan 26 '17 at 16:40