CBiscuit
03-15-2017, 11:16 PM
Hello VBA World.
I could use some help with the blow code. I have been reading and searching the internet for help and trying to understand the HOW TO code in VBA Powerpoint.
Not sure if I need all the DIM variables or should I list them all at the very beginning.
I just need someone to look over the code below and tell me where I am going wrong or what I did wrong, how to improve it Do I need the Sub Initialise() script.
I ben reading and trying other codes that I thought might work and after modifying them for my needs.
If need be I can send you the Powerpoint file, thanks.
I have just purchased several books to help me. The trick is learning what commands to use, hopefully one of the books that I ordered will provide me with a list. VBA
I REALLY need help with the last four Sub's
Sub shapeTextHappySmile()
Sub shapeTextSadSmile()
Sub CertificateBuld()
Sub PutText()
Option Explicit
Dim UserName As String
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
Dim printableSlide As Slide
Sub Initialise()
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
numberCorrect = numberIncorrect - numberTotal
numberTotal = (numberCorrect + numberIncorrect)
numberPercentage = ((numberCorrect / numberTotal) * 100) & "%"
End Sub
Sub TakeQuiz()
UserName = InputBox(Prompt:="Type Your Name! ")
MsgBox "Welcome To The Academic Online Tutorial Quiz " + UserName, vbApplicationModal, " Academic Online Tutorial Quiz"
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Correct()
MsgBox "Well Done! That the correct answer"
numberCorrect = numberCorrect + 1
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Wrong()
MsgBox "Sorry! That was the incorrect answer"
numberIncorrect = numberIncorrect + 1
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub shapeTextHappySmile()
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
numberCorrect = (numberTotal - numberIncorrect)
Application.ActivePresentation.Slides(40).Shapes(1).TextFrame.TextRange.Tex t = numberCorrect
numberPercentage = (numberCorrect / numberTotal) * 100
Application.ActivePresentation.Slides(40).Shapes(2).TextFrame.TextRange.Tex t = numberPercentage & "%"
End Sub
Sub shapeTextSadSmile()
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
numberIncorrect = (numberTotal - numberCorrect)
Application.ActivePresentation.Slides(41).Shapes(1).TextFrame.TextRange.Tex t = numberIncorrect
numberPercentage = (numberCorrect / numberTotal) * 100
Application.ActivePresentation.Slides(41).Shapes(2).TextFrame.TextRange.Tex t = numberPercentage & "%"
End Sub
Sub CertificateBuld()
Dim UserName As String
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
Dim Rdate
Rdate = Format(Date, "mmmm dd, yyyy")
If numberCorrect >= "14" Then
'Application.ActivePresentation.Slides(42).Shapes(8).TextFrame.TextRange.Te xt = " UNIVERSITY OF THE PEOPLE "
'With ActivePresentation.Slides(42).Shapes(9).TextFrame.TextRange.Text = Rdate & " ON " & Rdate & " WITH A SCORE OF " & numberPercentage & " %"
'With ActivePresentation.Slides(42).Shapes(10).TextFrame.TextRange.Text = UserName
Application.ActivePresentation.Slides(42).Shapes(8).TextFrame.TextRange.Tex t = " UNIVERSITY OF THE PEOPLE "
Application.ActivePresentation.Slides(42).Shapes(9).TextFrame.TextRange.Tex t = " ON " & Rdate & " WITH A SCORE OF " & numberPercentage & " %"
numberPercentage = (numberCorrect / numberTotal) * 100
Application.ActivePresentation.Slides(42).Shapes(10).TextFrame.TextRange.Te xt = UserName
Else
TakeQuiz
End If
End Sub
Sub PutText()
Dim UserName As String
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
Dim Rdate
Rdate = Format(Date, "mmmm dd, yyyy")
numberCorrect = numberIncorrect - numberTotal
numberPercentage = ((numberCorrect / numberTotal) * 100)
With ActivePresentation.Slides(40)
With .Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 500, 100)
.TextFrame.TextRange.Text = numberCorrect
With ActivePresentation.Slides(40)
With .Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 500, 100)
.TextFrame.TextRange.Text = numberPercentage
'If numberCorrect => "14" Then
With ActivePresentation.Slides(42).Shapes(10).TextFrame.TextRange.Text = UserName
With ActivePresentation.Slides(42).Shapes(9).TextFrame.TextRange.Text = Rdate
'End If
End With
End With
End With
End With
PrintCertificate
End Sub
I could use some help with the blow code. I have been reading and searching the internet for help and trying to understand the HOW TO code in VBA Powerpoint.
Not sure if I need all the DIM variables or should I list them all at the very beginning.
I just need someone to look over the code below and tell me where I am going wrong or what I did wrong, how to improve it Do I need the Sub Initialise() script.
I ben reading and trying other codes that I thought might work and after modifying them for my needs.
If need be I can send you the Powerpoint file, thanks.
I have just purchased several books to help me. The trick is learning what commands to use, hopefully one of the books that I ordered will provide me with a list. VBA
I REALLY need help with the last four Sub's
Sub shapeTextHappySmile()
Sub shapeTextSadSmile()
Sub CertificateBuld()
Sub PutText()
Option Explicit
Dim UserName As String
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
Dim printableSlide As Slide
Sub Initialise()
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
numberCorrect = numberIncorrect - numberTotal
numberTotal = (numberCorrect + numberIncorrect)
numberPercentage = ((numberCorrect / numberTotal) * 100) & "%"
End Sub
Sub TakeQuiz()
UserName = InputBox(Prompt:="Type Your Name! ")
MsgBox "Welcome To The Academic Online Tutorial Quiz " + UserName, vbApplicationModal, " Academic Online Tutorial Quiz"
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Correct()
MsgBox "Well Done! That the correct answer"
numberCorrect = numberCorrect + 1
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub Wrong()
MsgBox "Sorry! That was the incorrect answer"
numberIncorrect = numberIncorrect + 1
ActivePresentation.SlideShowWindow.View.Next
End Sub
Sub shapeTextHappySmile()
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
numberCorrect = (numberTotal - numberIncorrect)
Application.ActivePresentation.Slides(40).Shapes(1).TextFrame.TextRange.Tex t = numberCorrect
numberPercentage = (numberCorrect / numberTotal) * 100
Application.ActivePresentation.Slides(40).Shapes(2).TextFrame.TextRange.Tex t = numberPercentage & "%"
End Sub
Sub shapeTextSadSmile()
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
numberIncorrect = (numberTotal - numberCorrect)
Application.ActivePresentation.Slides(41).Shapes(1).TextFrame.TextRange.Tex t = numberIncorrect
numberPercentage = (numberCorrect / numberTotal) * 100
Application.ActivePresentation.Slides(41).Shapes(2).TextFrame.TextRange.Tex t = numberPercentage & "%"
End Sub
Sub CertificateBuld()
Dim UserName As String
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
Dim Rdate
Rdate = Format(Date, "mmmm dd, yyyy")
If numberCorrect >= "14" Then
'Application.ActivePresentation.Slides(42).Shapes(8).TextFrame.TextRange.Te xt = " UNIVERSITY OF THE PEOPLE "
'With ActivePresentation.Slides(42).Shapes(9).TextFrame.TextRange.Text = Rdate & " ON " & Rdate & " WITH A SCORE OF " & numberPercentage & " %"
'With ActivePresentation.Slides(42).Shapes(10).TextFrame.TextRange.Text = UserName
Application.ActivePresentation.Slides(42).Shapes(8).TextFrame.TextRange.Tex t = " UNIVERSITY OF THE PEOPLE "
Application.ActivePresentation.Slides(42).Shapes(9).TextFrame.TextRange.Tex t = " ON " & Rdate & " WITH A SCORE OF " & numberPercentage & " %"
numberPercentage = (numberCorrect / numberTotal) * 100
Application.ActivePresentation.Slides(42).Shapes(10).TextFrame.TextRange.Te xt = UserName
Else
TakeQuiz
End If
End Sub
Sub PutText()
Dim UserName As String
Dim numberCorrect As Integer
Dim numberIncorrect As Integer
Dim numberPercentage As Integer
Dim numberTotal As Integer
numberCorrect = 0
numberIncorrect = 0
numberPercentage = 0
numberTotal = 0
Dim Rdate
Rdate = Format(Date, "mmmm dd, yyyy")
numberCorrect = numberIncorrect - numberTotal
numberPercentage = ((numberCorrect / numberTotal) * 100)
With ActivePresentation.Slides(40)
With .Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 500, 100)
.TextFrame.TextRange.Text = numberCorrect
With ActivePresentation.Slides(40)
With .Shapes.AddTextbox(msoTextOrientationHorizontal, 100, 100, 500, 100)
.TextFrame.TextRange.Text = numberPercentage
'If numberCorrect => "14" Then
With ActivePresentation.Slides(42).Shapes(10).TextFrame.TextRange.Text = UserName
With ActivePresentation.Slides(42).Shapes(9).TextFrame.TextRange.Text = Rdate
'End If
End With
End With
End With
End With
PrintCertificate
End Sub