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


Download 1.37 Mb.
Pdf ko'rish
bet160/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   156   157   158   159   160   161   162   163   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

No News Is Bad News
VBA is not very talkative when it co mes to bugs. Once it en counters a bug
in a pro cedure, it just stops. You could have a pro cedure that is 100 lines long,
but if there is bug on the first line, the last 99 won’t ex ecute. And VBA will be si-
lent. If you’re like me, you click on the but ton again (and again and again and
again), muttering to your self that this has to work. On the one hand, it would be
nice if VBA told you something was wrong, a po lite
MsgBox
say ing, “I’m sorry,
but you have a prob lem in your pro cedure. I can not con tinue.” On the other
hand, com puter er ror mes sages are no to ri ous for be ing in com pre hen si ble. So,
would you rather get noth ing or “36549 invalid register access”?
Just treat noth ing as your pri vate er ror message. If you expect something
and noth ing hap pens, you know something is wrong, and it is time to start look -
ing for bugs.
The Er ror in Red
Sometimes the VBA Ed itor will catch an er ror and highlight it in red. As
you type your code and hit the Enter key (Return key on a Macintosh) af ter you
type a line, certain types of er rors will turn red. You can also get those same
The Er ror in Red 155


errors to turn red by clicking on any other line in your module. Keep in mind that
lines that end with an un derscore are con tinued on the next line, so you have to
hit En ter after the whole line is finished, or you have to click on a different line to 
get the er ror to turn red.
One common mistake is to type a line and im mediately switch back to
PowerPoint to test out your pro cedure. If you do this with out hit ting En ter or
clicking on an other line, you will miss the red, and your procedure will not work.
The line still will be red when you get back to the VBA Ed itor, but you will have
wasted the time go ing back to PowerPoint, run ning your pro cedure, and scratch-
ing your head for a few seconds while trying to fig ure out what went wrong.
Usually, with errors that turn red, you will also get a message right away
that tells you something about the error. For ex ample, Figure 9.1 shows a typ ical
error.

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   156   157   158   159   160   161   162   163   ...   191




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