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


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

myShape.Width = 200
MsgBox ("I am about to leave AddStar.")
End Sub
The above procedure is sim ilar to the one ear lier, except there is a different
error. If you try run ning the procedure with this er ror, noth ing will hap pen. You
won’t even get “En tering the procedure AddStar.” That means that it is time to
comment out some lines to try to track down the prob lem. Since noth ing can
work un til the shape is created, you prob ably want to start with the line after
Set
myShape . . . 
.
Sub AddStar()
Dim myShape As Shape
MsgBox ("En 
tering the pro 
cedure AddStar")
Set myShape = _
ActivePresentation.SlideShowWindow.View.Slide.Shapes.AddShape _
(mso16pointStar, 100, 100, 100, 100)
'MsgBox ("I just added the shape, and I’m about to add some text.")
'myShape.TextFrame.TextRange.Text = "Good job!"
'MsgBox ("I just added some text, and I’m about to change the color.")
'myShape.Fill.ForeColor.RGB = vbBlue
'MsgBox ("Color is changed; now I’ll change the size.")
'myShape.Height = 200
'myShape.Width = 200
'MsgBox ("I am about to leave AddStar.")
End Sub
160 De bug ging Tips


You’ll no tice that all the lines after the 
Set myShape
(ex cept
End Sub
) line are
green in the VBA Ed itor. These lines will not run. As far as VBA is concerned,
they are not even there.
Try run ning the procedure with all the comments. If it works, start remov-
ing the comments (just the single quotes, not the whole lines) from the line be-
low
Set myShape
. Run it again. If it works, remove the comment from the next
line and run it again. Keep removing one comment and run ning it again un til it
stops work ing. When it stops work ing, you have found the problem line. It must
be the last line from which you re moved the comment. If you have removed all
the comments and it still doesn’t work, then the prob lem is prob ably the 

Download 1.37 Mb.

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




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