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


Dim statement or the  Set myShape


Download 1.37 Mb.
Pdf ko'rish
bet167/191
Sana08.05.2023
Hajmi1.37 Mb.
#1442581
1   ...   163   164   165   166   167   168   169   170   ...   191
Bog'liq
2.2. Powerful PowerPoint For Educators

Dim
statement or the 
Set myShape
line.
If you go through this exercise, you’ll find that the problem is with the
Set
myShape
line. 
mso16PointStar
should be
msoShape16PointStar
. Of ten
the parameters of procedures are the kinds of er rors that will cause a procedure to 
not work at all, rather than work un til it reaches an error. But the best way to
eliminate er rors is to practice some pre vention techniques. They won’t prevent
all errors, but they will cut down on errors.
Com pil ing Your Code
Sometimes your code will not work, and you won’t know why. You might
have tried all the techniques above, but you still can’t find the bug. There is one
more technique that sometimes gives more in formation: compiling your code.
Certain kinds of errors are run time er rors. These hap pen when your code is 
running. The com puter doesn’t know that there is a bug un til it tries to run the
code. Other kinds of er rors are com pile er rors. These are er rors in which the
computer can see a problem be fore you run the code. Errors that turn red are one
type of compile error, gen erally errors that af fect one spe cific line of code. Other
errors do not turn red, but they make all the code stop working.
You can find compile errors by choosing “Compile VBAProject” from the
Debug menu in the VBA Ed itor. This will look over your code for any er rors that
the computer can catch before your code is run.
If you get a message that includes “Compile error,” you will prob ably get
some use ful in formation about what is wrong. It will prob ably high light where
the prob lem is in your code and de scribe the prob lem. For example, the error
“Argument not op tional” tells you that you are missing an argument for a proce-
dure or method. And you will know which pro cedure or method is missing the
argument be cause it will be high lighted. If you have more than one compile er-
ror, then you will have to do this again because the com piler stops on the first er-
ror it finds. Fix the first error and compile your pro ject again to see if there are
any more errors.
Com pil ing Your Code 161


Debugger
The VBA Ed itor co mes with a debugger. In some cases, this will be useful,
but it will not work well for most of our code. The debugger lets you set break-
points to stop your code at certain points as it runs. Un fortunately, this does not
work well for code that runs in Slide Show View, so it is not use ful for most of
our pur poses.

Download 1.37 Mb.

Do'stlaringiz bilan baham:
1   ...   163   164   165   166   167   168   169   170   ...   191




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