Create custom property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I create custom property in powerpoint through VBA Code. For
example, suppose I want all properties of a text box like height, width,
margins etc. and add those properties in document custom property tab.
 
How would I create custom property in powerpoint through VBA Code. For
example, suppose I want all properties of a text box like height, width,
margins etc. and add those properties in document custom property tab.

From PPT's vba help:

Application.ActivePresentation.CustomDocumentProperties _
.Add Name:="Complete", LinkToContent:=False, _
Type:=msoPropertyTypeBoolean, Value:=False

But be very cautious about adding more than just a few of these. You can cause
other problems by stuffing too much into custom properties.

Instead, consider using presentation or slide-level tags.

ActivePresentation.Tags.Add "TagName", "TagValue"

Or for example, on a slide:

Dim oSh as Shape
Dim oSl as Slide
Set oSl = ActivePresentation.Slides(1)
Set oSh = oSl.Shapes("TextBoxName")
With oSh

oSl.Tags.Add "W", cStr(.Width)
osl.Tags.Add "H", cStr(.Height)
' and so on

End With

The slide now has tags named W and H etc, all strings.

To use them elsewhere, assuming you still have a reference to the slide in oSl

CDbl(oSl.Tags("W")) ' gives you the width
 
Thank you very much Steve.

What will be the potential problem if I stuff too much into custom properties?

Can I apply these custom properties to objects in presentation?

Once again thanks for your help.

Nikhil
 
Thank you very much Steve.

What will be the potential problem if I stuff too much into custom properties?

There's a limited amount of space given over to storing custom properties, and it's
shared with link storage. Adding too much data could cause links to break, and/or
stop you from adding any more data or overwrite the data you've already added.
Can I apply these custom properties to objects in presentation?

Custom properties? No. They apply only to the presentation itself.

Tags? Yes. You can apply tags to the presentation, slides, and any shape on a
slide. And there's no data size limitation I know of.
 
Back
Top