Solved

Programmatically change default shape in PowerPoint

Posted on 2013-05-21
4
475 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Only one other response, and it was incomplete.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes how to make a simple, pseudo-random number generator in Microsoft PowerPoint. The code checks the generated numbers against a list of numbers already generated to prevent duplication. We used this as a youth group activity but…
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…
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: …

763 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

8 Experts available now in Live!

Get 1:1 Help Now