Powerful PowerPoint for Educators: Using Visual Basic for Applications to Make PowerPoint Interactive


ActivePresentation.SlideShowWindow.View.Next


Download 1.37 Mb.
Pdf ko'rish
bet170/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   166   167   168   169   170   171   172   173   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

ActivePresentation.SlideShowWindow.View.Next
The power of this is ap parent when you type something wrong. If you left
out a “t” in 
ActivePresentation
, for example, that would not be capitalized.
For ex ample, type the fol lowing:
activepresenation.slideshowwindow.view.next
An Ounce of Prevention 163


When you hit En ter, it changes to:
activepresenation.SlideShowWindow.View.Next
The fact that 
activepresenation
did not change in capitalization is a tip-off
that something is wrong.
This also works for any variables that you have de clared and pro cedures
you have written. The VBA Ed itor gets the cap italization that you want to use
from the 
Dim
state ment and the
Sub
statement (that’s why you have to type with
proper cap i tal iza tion in the
Dim
and 
Sub
state ments) and au to mat i cally ad justs
the capitalization as you type the vari able or pro cedure name in the fu ture. If the
cap i tal iza tion is not au to mat i cally ad justed for you, you have ei ther mis spelled
the name of the variable or pro cedure or have forgotten to declare the variable.
Misspelling the name of a variable or pro cedure gives the same results as
misspelling a keyword: The capitalization will not be changed by the VBA Ed i-
tor. For ex ample, type the following:
Dim userName As String
Sub YourName()
usernam = InputBox(prompt:="Type your name")
End Sub
Be cause 
userName
is mis spelled as 
usernam
, the 
n
did not get cap italized.
In dent ing
You might have no ticed that throughout the text, code ex amples were in -
dented in a very specific way. In denting helps you read the code. The com puter
will un derstand your code just fine without in denting, but you are more likely to
make mistakes without it. “Conditionals” in Chapter 8 discussed in denting briefly
because in denting is very help ful for reading
If
state ments. It is also help ful for
reading loops. The more complex the code, the more helpful in denting is.
You can use your own style for in denting, but whatever you de cide, you
should stick with it. The easiest way to in dent in the VBA Ed itor is to use the Tab
key. When you hit Tab at the be ginning of a line, the line will be in dented once.
When you hit En ter to go to the next line, the next line will be in dented at the
same level. If you don’t want it in dented, simply hit the Backspace key (Delete
on a Macintosh) or hold down the Shift key and hit Tab (shift-Tab). If you have a 
block of lines that you want to indent, you can high light them and hit Tab (or
shift-Tab if you want to un-indent them).
In this book, I have in dented three kinds of statements:
1.
Ev ery thing be tween a

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   166   167   168   169   170   171   172   173   ...   191




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling