VBA - reset placeholder

F

Fredrik E. Nilsen

Hi,

I'm programming an add-in in VBA. The add-in loads a toolbar with
buttons to control fill- and line-colours of shapes in a presentation.
The toolbar and buttons works perfectly but there is one problem:

If a user formats a placeholder and wants to reset it, the user has to
perform several actions. I want to include a button to reset the
placeholder to standard settings for text placeholders. That means
there should be no background and no line. I can set it to
fill.visible = msoFalse but that just makes the background invisible,
it doesn't actually remove it. With remove I mean the same setting as
if would use No fill from the Format shape dialogue.

If I try to record a macro it gives me this code:

With ActiveWindow.Selection.ShapeRange
.Fill.Visible = msoFalse
.Fill.Solid
.Fill.Transparency = 0#
End With
End Sub

When I try to run this code on my already formatted shapes, it doesn't
remove the background at all.

Any suggestions?
 
F

Fredrik E. Nilsen

Hi,

I'm programming an add-in in VBA. The add-in loads a toolbar with
buttons to control fill- and line-colours of shapes in a presentation.
The toolbar and buttons works perfectly but there is one problem:

If a user formats a placeholder and wants to reset it, the user has to
perform several actions. I want to include a button to reset the
placeholder to standard settings for text placeholders. That means
there should be no background and no line. I can set it to
fill.visible = msoFalse but that just makes the background invisible,
it doesn't actually remove it. With remove I mean the same setting as
if would use No fill from the Format shape dialogue.

If I try to record a macro it gives me this code:

With ActiveWindow.Selection.ShapeRange
.Fill.Visible = msoFalse
.Fill.Solid
.Fill.Transparency = 0#
End With
End Sub

When I try to run this code on my already formatted shapes, it doesn't
remove the background at all.

Any suggestions?

Never mind, I figured it out. Seems my ability to read is a bit
reduced tonight!
 
G

Guest

Hi Just a suggestion

The code you've recorded will crash if no shape is selected by the user the
error trap here will prevent this. Also fill.visible = msofalse is the same
as no fill.
if you only want placeholders affected then the IF lines do that, the
commented out lines would restrict it to text placeholders only

Sub whatever()
On Error GoTo errhandler
With ActiveWindow.Selection.ShapeRange
If .Type = msoPlaceholder Then
'If .PlaceholderFormat _
'.Type = ppPlaceholderTitle Or ppPlaceholderBody _
'Or ppPlaceholderCenterTitle Then
..Fill.Visible = msoFalse
..Line.Visible = msoFalse
End If
'End If
End With
Exit Sub
errhandler:
MsgBox "There's an error - did you select a shape?"
End Sub

There's some more vba stuff at our page you might want to look at how to
affect the whole presentation at once ie check and correct all placeholders
and adapt "Change font for whole presentation'

http://www.PPTAlchemy.co.uk
--
email john AT technologytrish.co.uk

Improve your skills - http://www.technologytrish.co.uk/ppttipshome.html
Need a dice throw for a ppt game?- http://www.technologytrish.co.uk/dice.html
 
F

Fredrik E. Nilsen

Hi Just a suggestion

The code you've recorded will crash if no shape is selected by the user the
error trap here will prevent this. Also fill.visible = msofalse is the same
as no fill.
if you only want placeholders affected then the IF lines do that, the
commented out lines would restrict it to text placeholders only

Sub whatever()
On Error GoTo errhandler
With ActiveWindow.Selection.ShapeRange
If .Type = msoPlaceholder Then
'If .PlaceholderFormat _
'.Type = ppPlaceholderTitle Or ppPlaceholderBody _
'Or ppPlaceholderCenterTitle Then
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
End If
'End If
End With
Exit Sub
errhandler:
MsgBox "There's an error - did you select a shape?"
End Sub

Thank you very much, this was very helpful!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top