Discussion:
Microsoft Visual Basic Compile Error: Invalid Outside Procedures
(too old to reply)
cotigchez
2009-04-27 22:04:02 UTC
Permalink
I am trying to create a password prompt for my computer science class
powerpoint. Such that the students cannot continue on untill they type in
the correct password. The code I'm using is the following:

Private Sub CommandButton1_Click()

If TextBox1.Text = "password" Then SlideShowWindows(Index:=1).View.Next

Else
MsgBox "Try Again", 16, "Incorrect Password"
End If
TextBox1.Text = ""

End Sub

Private Sub CommandButton2_Click()

End Sub

Private Sub TextBox1_Change()

End Sub

When I run the PPT any time my cursor moves into a form text box, MS Visual
Basic opens and I get the following error "Microsoft Visual Basic Compile
Error: Invalid Outside Procedures" with the following code:

ActiveWindow.Selection.ShapeRange(1).Name = "test23"

Private Sub TextBox1_Change()

End Sub

I don't know what to do!?? Help please!
ker_01
2009-04-28 00:01:19 UTC
Permalink
Does the password need to stay visible on the slide? If not, then try:

PasswordAttempt = Inputbox("Please enter the password","Password Required")

If PasswordAttempt = "password" then ... (etc)

Two thoughts:
1) putting your password in VBA is extremely unreliable. Any student who
knows to hit <F11> can open the VBE and look for the password.
2) This will only work if your presentation is opened with macros enabled.
I'm assuming you probably are using kiosk mode with no navigation buttons on
this slide (or something equivalent) to prevent the user from advancing if
they don't type the password.
Post by cotigchez
I am trying to create a password prompt for my computer science class
powerpoint. Such that the students cannot continue on untill they type in
Private Sub CommandButton1_Click()
If TextBox1.Text = "password" Then SlideShowWindows(Index:=1).View.Next
Else
MsgBox "Try Again", 16, "Incorrect Password"
End If
TextBox1.Text = ""
End Sub
Private Sub CommandButton2_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
When I run the PPT any time my cursor moves into a form text box, MS Visual
Basic opens and I get the following error "Microsoft Visual Basic Compile
ActiveWindow.Selection.ShapeRange(1).Name = "test23"
Private Sub TextBox1_Change()
End Sub
I don't know what to do!?? Help please!
ker_01
2009-04-28 00:09:01 UTC
Permalink
Followup to my previous response: I can't tell from the info provided why you
would get that error just on entering a text box. Do you have other event
handlers for page activity, like TextBox1_Change?

Also, a suggestion: go in to design mode, and look at the properties for
your commandbuttons- change "take focus on click" to false for all of them.
I'm not sure how the focus affects the Powerpoint events, but it can really
mess things up in Excel under certain conditions.

HTH,
Keith
Post by ker_01
PasswordAttempt = Inputbox("Please enter the password","Password Required")
If PasswordAttempt = "password" then ... (etc)
1) putting your password in VBA is extremely unreliable. Any student who
knows to hit <F11> can open the VBE and look for the password.
2) This will only work if your presentation is opened with macros enabled.
I'm assuming you probably are using kiosk mode with no navigation buttons on
this slide (or something equivalent) to prevent the user from advancing if
they don't type the password.
Post by cotigchez
I am trying to create a password prompt for my computer science class
powerpoint. Such that the students cannot continue on untill they type in
Private Sub CommandButton1_Click()
If TextBox1.Text = "password" Then SlideShowWindows(Index:=1).View.Next
Else
MsgBox "Try Again", 16, "Incorrect Password"
End If
TextBox1.Text = ""
End Sub
Private Sub CommandButton2_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
When I run the PPT any time my cursor moves into a form text box, MS Visual
Basic opens and I get the following error "Microsoft Visual Basic Compile
ActiveWindow.Selection.ShapeRange(1).Name = "test23"
Private Sub TextBox1_Change()
End Sub
I don't know what to do!?? Help please!
Steve Rindsberg
2009-04-28 01:37:01 UTC
Permalink
Post by ker_01
1) putting your password in VBA is extremely unreliable. Any student who
knows to hit <F11> can open the VBE and look for the password.
Just a comment:

If the code's in a module and the project is protected, they'd have to be a bit
more devious than that. Not perfectly secure, still, but a lot harder to get at
than Alt+F11 and peek.

==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/
Steve Rindsberg
2009-04-28 01:11:14 UTC
Permalink
Post by cotigchez
I am trying to create a password prompt for my computer science class
powerpoint. Such that the students cannot continue on untill they type in
Private Sub CommandButton1_Click()
If TextBox1.Text = "password" Then SlideShowWindows(Index:=1).View.Next
Else
MsgBox "Try Again", 16, "Incorrect Password"
End If
TextBox1.Text = ""
End Sub
Private Sub CommandButton2_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
When I run the PPT any time my cursor moves into a form text box, MS Visual
Basic opens and I get the following error "Microsoft Visual Basic Compile
ActiveWindow.Selection.ShapeRange(1).Name = "test23"
Private Sub TextBox1_Change()
End Sub
I don't know what to do!?? Help please!
What that error message is trying, in its own clumsy, obtuse and generally
useless way, is this:

All code must be within a Subroutine or Function. The line that's causing the
error isn't.

Easily fixed:

Delete it or comment it out by putting a ' character at the beginning of the
line.


==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/

PPTools add-ins for PowerPoint
http://www.pptools.com/
cotigchez
2009-04-28 15:56:01 UTC
Permalink
Commenting the line out worked!! Thank you so much. This problem has been
driving me crazy. Thanks again!
Post by Steve Rindsberg
Post by cotigchez
I am trying to create a password prompt for my computer science class
powerpoint. Such that the students cannot continue on untill they type in
Private Sub CommandButton1_Click()
If TextBox1.Text = "password" Then SlideShowWindows(Index:=1).View.Next
Else
MsgBox "Try Again", 16, "Incorrect Password"
End If
TextBox1.Text = ""
End Sub
Private Sub CommandButton2_Click()
End Sub
Private Sub TextBox1_Change()
End Sub
When I run the PPT any time my cursor moves into a form text box, MS Visual
Basic opens and I get the following error "Microsoft Visual Basic Compile
ActiveWindow.Selection.ShapeRange(1).Name = "test23"
Private Sub TextBox1_Change()
End Sub
I don't know what to do!?? Help please!
What that error message is trying, in its own clumsy, obtuse and generally
All code must be within a Subroutine or Function. The line that's causing the
error isn't.
Delete it or comment it out by putting a ' character at the beginning of the
line.
==============================
PPT Frequently Asked Questions
http://www.pptfaq.com/
PPTools add-ins for PowerPoint
http://www.pptools.com/
Continue reading on narkive:
Search results for 'Microsoft Visual Basic Compile Error: Invalid Outside Procedures' (Questions and Answers)
5
replies
can i get question answer of asp.net ?
started 2006-10-11 00:02:47 UTC
software
Loading...