Solved

Programmatically change default shape in PowerPoint

Posted on 2013-05-21
4
478 Views
Last Modified: 2013-06-01
I know I can stylize a shape in PowerPoint, then right-click and "set shape as default."  But I want to provide a client with a toolbar where they can switch to several pre-set shape stylings.  Does anyone know how to programmatically set the default shape properties using VBA, not just once, but potentially multiple times?

Thanks
0
Comment
Question by:versatilebb
  • 3
4 Comments
 
LVL 23

Expert Comment

by:JSRWilson
ID: 39186630
There can only be one default.

To get what you want you would need to create an AddIn it would be a lot easier to apply the chosen style to selected shapes.

It would probably create a gallery of shapes on the ribbon and then use the pickup and apply methods to apply the style to a shape.
0
 

Author Comment

by:versatilebb
ID: 39189133
Thanks,

I understand there can only be one default, but if I can set that default programmatically by having the user click a button, no reason I couldn't keep changing it.  

I am in fact creating an Add-In for this client, and am planning to use a gallery approach.

But I don't want the user to have to create a shape, then apply the custom style after the fact.  I'd like it to work like the built-in PowerPoint galleries, where you choose Insert, Shape, select a shape from the gallery, then when you create it, it has the chosen style already in place.  Can you think of a way to do this?

Speaking of which, I found a method to add custom colors to the built-in color picker dialog by adding to the theme1.xml file.  Is there a similar technique to modify built-in PowerPoint galleries?
0
 

Accepted Solution

by:
versatilebb earned 0 total points
ID: 39200252
Found my answer.

There's a shapes method called "SetShapesDefaultProperties"

So, I create a dummy shape, stylize it the way I want, capture those settings as the default shape, then delete the dummy shape.  Thereafter, any shape the user creates has those settings.

Set myshp = ActivePresentation.Slides(showingslide).Shapes.AddShape(msoShapeRectangle, 10, 10, 10, 10)
With myshp
    .Fill.ForeColor.RGB = RGB(102, 0, 102)
    .Line.Visible = msoFalse
    .TextFrame.AutoSize = ppAutoSizeNone
    .TextFrame.TextRange.Font.Size = 18
    .TextFrame.VerticalAnchor = msoAnchorMiddle
    .TextFrame.TextRange.Font.Name = "Verdana"
    .TextFrame.TextRange.Font.Italic = msoFalse
    .TextFrame.TextRange.Font.Bold = msoFalse
    .TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
    .SetShapesDefaultProperties
End With
myshp.Delete

Open in new window

0
 

Author Closing Comment

by:versatilebb
ID: 39212611
Only one other response, and it was incomplete.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to simulate drawing numbers or names from a hat or bag using vba in PowerPoint and prevents duplicate items being selected. It’s not difficult to choose a (semi) random number in vba. The RND function returns a decimal numb…
Most folk recognise that Microsoft Excel, being a numbers-and-formulae-centric application attracts programmers due to the natural fit in mindset. Conversly, when opening Microsoft's dominant presentation creative application, few consider what…
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now