New to Macros in PPT

  • Thread starter Thread starter St@cy
  • Start date Start date
S

St@cy

PP2003

I want to create a button which will ask for a student's name (store for
later) and advance to the third slide in a presentation. The following
compiles but doesn't do anything.

Private Sub NEWUSER_BUTTON_Click()
Dim student As String
student = InputBox("What is your name?")
With ActivePresentation
.GotoSlide 3
End With
End Sub
 
Hi Stacy, since you are new to coding, I should also point out some other
things you need to watch for in this sort of coding.

What if the user did not enter any name in the Input Box? do you still want
to go to Slide 3?
Is there a problem if the same name is used more than once?
Why add the With statement for a single line of code? Trim it out and just
use...
ActivePresentation.SlideShowWindow.View.GotoSlide 3

Bill D.
 
It still didn't do anything. (Yes, I'm in presentation mode)
The button creates the thin black line inside, indicating it has been
pressed and working, but no message box appears nor does it advance to slide
3.
I tried commenting out the ask line and the goto line individually to test
if either line is working - neither worked.
I've just been following the examples in MS Help. Is there anything else I
need to declare somewhere else for this to work?
 
Thanks Bill.
I wondered about that. I was just following the example in MS Help.
In any case, it is still not working. Read my reply to the answer above.

Yeah, I'll tackle the name thing later. Eventually, I need it to create a
dat file or transfer student's names and scores to an Excel file, which then
can be pull back into the PPT later. I'm attempting to create an interactive
course. I figured I'd tackle one task at a time. You'll probably see me a
lot this week. ;)
 
The example works when the security level is set low enough. By default, MS
prevents (rant deleted) VBA from running.


I would recommend ...
Check your Macro Security level and have it set to low or medium. Close
PowerPoint then re-open. It should run.

Here is how I would code this to prevent null names. Note the Underscore
characters that allow you to wrap the code line.

Private Sub CommandButton1_Click()
If Len(Trim$(InputBox("What is your name?"))) _
0 Then SlideShowWindows(1) _
.View.GotoSlide 3
End Sub

Bill
 
Back
Top