[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 894
  • Last Modified:

Programmatically change PowerPoint picture placeholder from rectangle to oval?

I'm building a PowerPoint (2010) template to conform to our new company design.  It includes a lot of round picture placeholders.   Manually, it's easy to create a new slide layout, insert a picture placeholder (which comes in by default as a rectangle), then use change shape to change it to an oval.   I just need to accomplish that with VBA.  The following code creates a new layout and adds the picture placeholder.  

layoutcount = ActivePresentation.Designs(1).SlideMaster.CustomLayouts.Count

Set newlayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts _
    .Add(layoutcount + 1)

Set ph = newlayout.Shapes.AddPlaceholder(ppPlaceholderPicture, _
    Left:=100, Top:=200, Width:=100, Height:=100)

Open in new window


Now how would I change "ph" to an oval?

Thanks
0
Bryce Bassett
Asked:
Bryce Bassett
  • 2
1 Solution
 
JSRWilsonCommented:
'Declare the variables!
Dim ph As Shape
Dim layoutcount As Long
Dim newlayout As CustomLayout

layoutcount = ActivePresentation.Designs(1).SlideMaster.CustomLayouts.Count

Set newlayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts _
    .Add(layoutcount + 1)

Set ph = newlayout.Shapes.AddPlaceholder(ppPlaceholderPicture, _
    Left:=100, Top:=200, Width:=100, Height:=100)
ph.AutoShapeType = msoShapeOval

Open in new window

0
 
Bryce BassettFreelance VBA programmerAuthor Commented:
Perfectly simple!

Thanks.

Yes, I always declare my variables and use Option Explicit.  I just was posting a snippet of my code.  But good reminder
0
 
JSRWilsonCommented:
You'd be amazed how many folk don't think declaring variables correctly is important! (Well maybe not)
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now