Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Programmatically change default shape in PowerPoint

Posted on 2013-05-21
4
Medium Priority
?
500 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:Bryce Bassett
  • 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:Bryce Bassett
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:
Bryce Bassett 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:Bryce Bassett
ID: 39212611
Only one other response, and it was incomplete.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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…
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.
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: …
Suggested Courses

963 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