Assigning Build Levels to Text
So, as I may have mentioned, I’m currently writing a few articles dealing with PowerPoint animations. One of the interesting concepts here is that of the build, in which the sub-objects of a shape enter the slide, either individually or in subsets, to build the final shape. One of the most prevalent uses of this is the dreaded ‘text build’, where the various bullet points of a text box enter a slide.
Because you assign build effects to a shape’s text based on the indent levels of the text paragraphs, such as first-level, second-level, etc., it’s worth discussing how to specify the indent level for text.
Each Shape has a TextFrame object, which in turn has a TextRange object that contains all the text in a shape. You can then use various methods of the TextRange object to return other TextRange objects that represent various subset of the text in the shape, such as paragraphs, sentences, lines, runs, words, or characters. The IndentLevel property of a given TextRange returns or sets the indent level assigned to that text.
You can specify one build level per paragraph. If you assign an indent level to a text range that is a sub-set of a paragraph, such as a single sentence or character run, that indent level is applied to the entire paragraph. If you assign an indent level to a text range that encompasses text in multiple paragraphs, then each of those paragraphs is assigned the specified indent level. For example, if you change the indent level of a sentence, word, or run in a second-level paragraph to 3, then the indent level for the entire paragraph is set to 3.
Because the objects returned by the various TextRange methods are TextRange objects themselves, they have all the methods and properties of that type. For example, TextRange.TextRange.Paragraphs.Count returns the number of paragraphs contained in a shape’s text frame. Use the Paragraphs method to set the indent level of your paragraphs.
The code below adds four paragraphs, or bullet points, to a shape on a slide. It then uses the Paragraphs method to individually return and set the indent level of each of those paragraphs.
.Text = "This is the first level heading" & vbCrLf
.InsertAfter "This is the second level heading" & vbCrLf
.InsertAfter "This is the third level heading" & vbCrLf
.InsertAfter "This is another first level heading"
.Paragraphs(1, 1).IndentLevel = 1
.Paragraphs(2, 1).IndentLevel = 2
.Paragraphs(3, 1).IndentLevel = 3
.Paragraphs(4, 1).IndentLevel = 1
And here’s how the text would display on the slide:
· This is the first level heading
· This is the second level heading
· This is the third level heading
· This is another first level heading