VBA Quiz asks to save changes

T

trueborn.ankalime

I've put together a PowerPoint presentation quiz, based on the
eminently useful examples generously provided by David Marcovitz...
but I think I've broken it with my VBA noobness.

It's supposed to go through the slides in show mode, give the quiz,
calculate the score and allow the person to print a certificate at the
end. And it works great... for me, on my computer. It works great for
another co-worker of mine, on his computer. But two other co-workers
get a dialog box after they click the button to print their
certificate that asks them if they want to save changes.

What's REALLY funny is that this presentation is part one of a two
part training. Part two works fine, for everyone. And the code is
exactly the same except for slide numbers.

The file is accessed from a file server, so it is not saved locally to
the user's hard drive, if that makes a difference.

What did I do wrong?

Sub PrintablePage()
Dim printableSlide As Slide
Dim backgroundImage As Shape
Dim restartButton As Shape
Dim printButton As Shape
Dim exitButton As Shape

Set printableSlide = _
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
If numCorrect > 6 Then
With ActivePresentation
.Slides(printableSlideNum).Design = .Designs(3)
End With

printableSlide.Shapes(1).TextFrame.TextRange.Text = _
"Certificate of Completion"
printableSlide.Shapes(1).TextFrame.TextRange.Font.Size = 28

' If the number of questions in the test changes, change the
number by which numCorrect is divided in the formula below

printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"This certifies that" & Chr$(13) & _
firstlastName & Chr$(13) & _
"successfully completed " & Chr$(13) & _
"Quality Management System Training" & Chr$(13) & _
"Part 1 - The Quality Management" & Chr$(13) & _
"System Requirements"
printableSlide.Shapes(2).TextFrame.TextRange.Lines(2,
1).Font.Bold = msoTrue
printableSlide.Shapes
(2).TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
printableSlide.Shapes
(2).TextFrame.TextRange.ParagraphFormat.Bullet = msoFalse
printableSlide.Shapes(2).TextFrame.TextRange.Font.Size = 24

ActivePresentation.PrintOut From:=printableSlideNum, _
To:=printableSlideNum
MsgBox ("Your certificate is printing. The training module
will now close.")
ActivePresentation.Slides(printableSlideNum).Delete
ActivePresentation.Saved = True
ActivePresentation.Close
Application.Quit
End If

End Sub
 
T

trueborn.ankalime

On Feb 27, 9:30 am, (e-mail address removed) wrote:
[major snippage]
What did I do wrong?

Sorry for replying to my own post, but I've discovered one more thing:
the users having the problem are using Office 2007, whereas those of
us not having the problem are using Office 2003. There must be a
solution, since one of the presentations works as desired, but I'm
stumped.

Cindy
 
D

David Marcovitz

Cindy,

I have been noticing a few anomalies with VBA and 2007. I haven't seen
this one yet. What happens if you cut out the ActivePresentation.Close
line? I believe that the Application.Quit will quit PowerPoint without
asking to save while while the .Close command will ask to save. I wonder
if 2007 is ignoring the ActivePresenation.Saved = True line. That would
be very annoying.

--David
 
T

trueborn.ankalime

Hi David,

Here's what I did... As I mentioned in my first post, this was a two
part training program, and the presentation for part 2 worked fine. So
I had someone compare the VBA for the two files, and they were
identical with the exception of some specified slide numbers in the
VBA code. The only other thing I could conclude was that there was
some property of the part 1 file that differed from part 2 that was
causing the problem, but I couldn't for the life of me figure out what
it could be. I mean, I based part 2 on part 1 -- they should have been
identical in every way except for slide content.

I was stumped, so I tried a quick and dirty solution -- I inserted the
slides from the part 1 presentation into the part 2 presentation,
deleted the part 2 slides and resaved the file as "part 1". It worked.

Unfortunately, I ran out of hours to work on the project, so I
couldn't pursue it further, but I appreciate your response and when I
have some time to play around with it, I'll look at it again; I'd
really like to know exactly what the problem is myself.

Thanks much!
Cindy
 
J

johnwatkins35

I've put together a PowerPoint presentation quiz, based on the
eminently useful examples generously provided by David Marcovitz...
but I think I've broken it with my VBA noobness.

It's supposed to go through the slides in show mode, give the quiz,
calculate the score and allow the person to print a certificate at the
end. And it works great... for me, on my computer. It works great for
another co-worker of mine, on his computer. But two other co-workers
get a dialog box after they click the button to print their
certificate that asks them if they want to save changes.

What's REALLY funny is that this presentation is part one of a two
part training. Part two works fine, for everyone. And the code is
exactly the same except for slide numbers.

The file is accessed from a file server, so it is not saved locally to
the user's hard drive, if that makes a difference.

What did I do wrong?

Sub PrintablePage()
Dim printableSlide As Slide
Dim backgroundImage As Shape
Dim restartButton As Shape
Dim printButton As Shape
Dim exitButton As Shape

Set printableSlide = _
ActivePresentation.Slides.Add(Index:=printableSlideNum, _
Layout:=ppLayoutText)
If numCorrect > 6 Then
With ActivePresentation
.Slides(printableSlideNum).Design = .Designs(3)
End With

printableSlide.Shapes(1).TextFrame.TextRange.Text = _
"Certificate of Completion"
printableSlide.Shapes(1).TextFrame.TextRange.Font.Size = 28

' If the number of questions in the test changes, change the
number by which numCorrect is divided in the formula below

printableSlide.Shapes(2).TextFrame.TextRange.Text = _
"This certifies that" & Chr$(13) & _
firstlastName & Chr$(13) & _
"successfully completed " & Chr$(13) & _
"Quality Management System Training" & Chr$(13) & _
"Part 1 - The Quality Management" & Chr$(13) & _
"System Requirements"
printableSlide.Shapes(2).TextFrame.TextRange.Lines(2,
1).Font.Bold = msoTrue
printableSlide.Shapes
(2).TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
printableSlide.Shapes
(2).TextFrame.TextRange.ParagraphFormat.Bullet = msoFalse
printableSlide.Shapes(2).TextFrame.TextRange.Font.Size = 24

ActivePresentation.PrintOut From:=printableSlideNum, _
To:=printableSlideNum
MsgBox ("Your certificate is printing. The training module
will now close.")
ActivePresentation.Slides(printableSlideNum).Delete
ActivePresentation.Saved = True
ActivePresentation.Close
Application.Quit
End If

End Sub

Cindy is there a way i can get a copy of your quiz? i am trying to create a quiz with roughly 48 slides and a certificate at the end.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top