• No se han encontrado resultados

Memorias Descriptivas del Sistema de Agua Antecedentes y objetivos de estudio:

PRECIO TOTAL POR M Ó DULO ES DE USD MIL QUINIENTOS SIETE CON 11/100 D Ó LARES DE LOS

1. Memorias Descriptivas del Sistema de Agua Antecedentes y objetivos de estudio:

Now, suppose you want to add something to the text in your shape, rather than re place the text. Re member the am persand (&). This is used to join two pieces of text together. We used it when we wanted to dis play text in a MsgBox

that included “You are do ing well” and the user’s name. We can use it here to join what is already in the text box with some ad ditional text. Once we join to - gether the text we need to stick the joined together text into the.Text of the shape.

Sub AddHello()

With ActivePresentation.SlideShowWindow.View.Slide _ .Shapes("Rect angle 3")

.TextFrame.TextRange.Text = _

.TextFrame.TextRange.Text & Chr$(13) & "Hello Mother" End With

End Sub

TheWith line (including the next line that is really part of that line due to the un - derscore) tells the computer that we are go ing to do something with the shape named “Rectangle 3” on the current slide. If the current slide is a Bulleted List slide, “Rect angle 3” re fers to the bulleted list area (the main area for text).

.TextFrame.TextRange.Text = _

tells the com puter that we are go ing to put something into the text area of that slide. Af ter the equal sign, the next line

.TextFrame.TextRange.Text & Chr$(13) & "Hello Mother"

tells the com puter what we are go ing to put into the text area. We are go ing to • start with what is already there ( .TextFrame.TextRange.Text ); • add to that a spe cial character,Chr$(13), which is the New Para -

graph symbol (just like hit ting “Enter” or “Return” if you were typ - ing the text into the text area your self); and

• add the text “Hello Mother”.

This will have the ef fect of taking what was already in the bulleted list and add - ing a new line with the words “Hello Mother.” Remember, you can do any thing with the text that you want. We added “Hello Mother” as a simple example. You could have added the user’s name. For example, you might write an in teractive story with your students in which the student types a name at the beginning of the story, and the name is used dur ing the story by replacing or modifying the text in one of the slides:

Sub BrickPig()

With ActivePresentation.Slides(7).Shapes("Rect angle 3") .TextFrame.TextRange.Text = .TextFrame.TextRange.Text & _ "And then the third pig, " & userName & _

", built a house of bricks. The brick house " & _ "was very strong."

End With End Sub

This takes the shape named “Rectangle 3” on the seventh slide and adds text to it that includes the user’s name (assuming you have used theYourNamepro ce dure at some previous point to get the user’s name). If “Rectangle 3” is a Placeholder (see be low for in formation about Placeholders), be sure it has something in it when you try to run this code, or your text will not show up un til after you exit Slide Show View.

As another example, imagine that you are hav ing a class discussion, and you want to re cord the stu dents’ comments in your PowerPoint presentation. Perhaps you are discussing the signs of spring, and you want the class to tell you signs of spring re lated to plants and animals. Without technology, you would write the in formation on the blackboard. However, this is awkward if you are us - ing PowerPoint as part of the dis cussion; it is awkward to run from the com puter to the blackboard, and it is awk ward to flip the lights off and on so students can see the screen and the blackboard alternately. In stead, use this simple code to put the text right into the PowerPoint presentation:

Sub AddPlants()

Dim newstuff As String

newstuff = InputBox("What is a plant sign of Spring?") If newstuff "" Then

With ActivePresentation.SlideShowWindow.View.Slide _ .Shapes(2).TextFrame.TextRange

.Text = .Text + Chr$(13) + newstuff End With

End If End Sub

Sub AddAnimals()

Dim newstuff As String

newstuff = InputBox("What is an an imal sign of Spring?") If newstuff "" Then

With ActivePresentation.SlideShowWindow.View.Slide. _ Shapes(3).TextFrame.TextRange

.Text = .Text + Chr$(13) + newstuff End With

End If End Sub

This code works on a slide with two text boxes that you add as the second and third shapes on the slide, and it works with a 2-Col umn Text slide. Just be- ware that if you add text to an empty Placeholder (that’s one of those text boxes that says “Click to add text” or “Click to add title” be fore you put any thing in it, Ma nip u lat ing Text in Ob jects 81

i.e., your ti tle, left col umn, and right column in the 2-Col umn Text slide), your text will not show up un til you exit the slideshow. To avoid this prob lem, ei ther use a Ti tle Only slide and draw your own text boxes or type a space in the text area so the Place holder is not empty.

The code works with the slide shown in Fig ure 6.6. This figure shows the slide be fore and af ter typing some text. In this case, you would have pressed the Plant but ton (which is tied to the AddPlant pro cedure) twice and the An imal button (which is tied to the AddAnimal pro cedure) once, having been prompted by an InputBox each time to name a sign of spring. TheIf state ment in each pro ce dure (along with the cor re spond ing End If) can be left off, but it provides you with an es cape if you accidentally hit the wrong but ton: Simply click OK with out typ ing any thing. TheIf statement asks if you have typed something (i.e., the text you typed is not the empty string), and it only adds the text to the slide if the answer is yes.

Figure 6.6. Signs of Spring Dis cussion Slide—Before and Af ter

Of course the entire ex ample could be simplified with one procedure, one text box, and one but ton if you don’t want to or ganize stu dent responses into two columns. It can also be complicated by add ing more similar procedures, more text boxes, and more but tons if you want to di vide student responses into more than two areas.