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


Fig ure 9.1. Typ i cal Com pile Er ror


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

Fig ure 9.1. Typ i cal Com pile Er ror
This is a compile error. A com pile error hap pens when the com puter can’t even
figure out what to try to do. In this case, it is prob ably look ing for a close pa ren-
thesis. It even sug gests that that might be the case. A line like the fol lowing will
generate the error in Figure 9.1:
MsgBox ("hello"
Sometimes these mes sages are helpful, and sometimes they are not. Al-
though the message in Fig ure 9.1 indicates that we are missing a comma or a
close parenthesis, sometimes a mes sage like that is the re sult of some completely
dif fer ent problem.
Try typ ing the following pro cedure to add a 16-point star to your current
slide:
Sub AddStar()
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddShape _
(msoShape16pointStar
End Sub
156 De bug ging Tips


If you hit Enter (or click any where else in your mod ule) after typing
msoShape16pointStar
, you will get the er ror in Figure 9.1, and the line with
the er ror will turn red. In this case, we are miss ing the close pa renthesis, so we
can add it:
Sub AddStar()
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddShape _
(msoShape16pointStar)
End Sub
Now when you hit Enter, the line doesn’t turn red. Does that mean that it works?
No, it does not. But we’re ready to try it out to see if it works.
Create a but ton and tie it to the pro cedure
AddStar
. Go to Slide Show
View and click on your but ton. No news is bad news. The VBA Ed itor (or more
accurately, the VBA com piler) could n’t find anything wrong as you typed, but
when VBA tried to run the pro cedure, it could n’t fig ure it out, so it just gave up.
Unfortunately, we don’t have any more clues as to what is wrong. How-
ever, since we are adding a shape, we might re member that we need to tell VBA
where the shape should go and how big it should be:

Download 1.37 Mb.

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




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