Microsoft Office Automation with Visual FoxPro

Standardizing the appearance of text

Text is controlled by the TextStyles collection of the SlideMaster object. The collection has three objects. The first is the default style, used when a shape with text is added. The second is the title style used for all title placeholder objects. The last object is the body style, used for all of the other placeholders in an AutoLayout.

Within each TextStyle object is a collection of Level objects (Help refers to these as TextStyleLevel objects, though you access them through the Level property). Text levels are easiest to explain in terms of bullets: normally, each level is indented from the previous, and each level has a different bullet character and font characteristics though each level does not necessarily have to be indented or bulleted. Figure 3 shows the master slide as seen in PowerPoint, which shows the default characteristics for each level. PowerPoint supports five levels.

Each Level object contains a Font object and a ParagraphFormat object. The ParagraphFormat object contains the Bullet object. These objects are covered in Chapter 10, "PowerPoint Basics," and have the same properties and methods when used for Levels as they do for TextRanges.

You might use the TextStyles and Levels collections to change the color and font for the Title objects. Usually slide show backgrounds are a darker color, like medium to dark blue, to ensure readability. When the background is dark, the text needs to be light perhaps a shade of yellow. Additionally, it is usual to use an eye-catching sans-serif font for a title. The following code demonstrates this. Figure 4 shows the results.

#DEFINE ppTitleStyle 2

#DEFINE rgbYellow RGB(255,255,0)

WITH oPresentation.SlideMaster.TextStyles[ppTitleStyle].Levels[1].Font

.Name = "Arial"

.Color.RGB = rgbYellow

ENDWITH

Figure 3. The default SlideMaster as seen in PowerPoint. Notice the levels shown in the Object Area.

Figure 4. The SlideMaster in PowerPoint. This shows the results of the example code that sets the Titles and Placeholder default text.

As the example illustrates, a Title uses the Levels collection. A Title can have multiple Levels, perhaps for a title and subtitle in the same rectangle. While levels are useful for changing fonts in Titles, they really excel in placeholders, especially when bullets are used.

The next example shows how to format the first three Levels in placeholders. The ppBodyStyle constant is used to reference the third TextStyle object. The first level is formatted to dark blue. The bullet character is a dot, but we ve turned it off. The character is set so it can be turned on when needed. The second level is set similarly, but the bullet is left on. The third level is slightly smaller, medium cyan, and uses an en-dash bullet character. The result is shown in Figure 4.

#DEFINE ppBodyStyle 3

#DEFINE rgbDarkBlue RGB(0, 0, 128)

#DEFINE rgbMediumCyan RGB(0, 192, 192)

* Set Level One

WITH oPresentation.SlideMaster.TextStyles[ppBodyStyle].Levels[1]

WITH .Font

.Name = "Arial"

.Color.RGB = rgbDarkBlue

.Size = 20

ENDWITH

WITH .ParagraphFormat.Bullet

* Set bullet character to a dot (use 149 if using PowerPoint 97)

.Character = 8226

.Visible = .F. && Don't show the bullet!

ENDWITH

ENDWITH

* Set Level Two

WITH oPresentation.SlideMaster.TextStyles[ppBodyStyle].Levels[2]

WITH .Font

.Name = "Arial"

.Color.RGB = rgbDarkBlue

.Size = 20

ENDWITH

* Set bullet character to a dot (use 149 if using PowerPoint 97)

.ParagraphFormat.Bullet.Character = 8226

ENDWITH

* Set Level Three

WITH oPresentation.SlideMaster.TextStyles[ppBodyStyle].Levels[3]

WITH .Font

.Name = "Arial"

.Color.RGB = rgbMediumCyan

.Size = 18

ENDWITH

* Set bullet character to an en-dash (use 150 if using PowerPoint 97)

.ParagraphFormat.Bullet.Character = 8211

ENDWITH

Similar code can be used to set the default text for added shapes using the constant ppDefaultStyle to access the first TextStyle object.

Copyright 2000 by Tamar E. Granor and Della Martin All Rights Reserved

Категории