I have created a slide which shows club photos and sponsors rolling along sides and bottom. and now want to use that slide to do a raffle draw. I have done it successfully with userform but its appearance on the slide is a bit clunky.
the basic process is
click on a text box -has a 0 displayed on the slide.
message box is displayed to enter start number
message box is displayed to enter the last number
textbox now shows winning number - from random generator
operator now clicks again for redraw if not claimed or for second or third prize.
in code below the second (or third time through) results in 1 as the number displayed not a new random generated number as Endvalue = 1. (On the userform I kept the EndValue in a another textbox that was hidden)
I would also want to set the displayed text back to 0 at the end or between the draw from 1st to subsequent other draws (I will add an End) command button could I do that then?)
Sub UpdateRandomNumber(oSh As Shape) Dim X As Long Dim EndValue As Integer Dim StartValue As Integer Dim Message, Title, Default Dim MyValue As Integer ' Start Number If oSh.TextFrame.TextRange.Text = "0" Then Message = "Enter Raffle Start Number" ' Set prompt. Title = "Raffle Start Number" ' Set title. Default = "1" ' Set default. StartValue = InputBox(Message, Title, Default) ' End Number Message = "Enter Raffle End Number" ' Set prompt. Title = "Raffle End Number" ' Set title. Default = "12" ' Set default. EndValue = InputBox(Message, Title, Default) ' As a test Display dialog box at position 100, 100. MyValue = InputBox(Message, Title, EndValue, 100, 100) End If X = EndValue ' How do I get end value to = what was entered on ist time through? oSh.TextFrame.TextRange.Text = CStr(Random(X)) SlideShowWindows(1).View.GotoSlide (SlideShowWindows(1).View.Slide.SlideIndex) ' Do it again as a test SlideShowWindows(1).View.GotoSlide (SlideShowWindows(1).View.Slide.SlideIndex) oSh.TextFrame.TextRange.Text = CStr(Random(X)) 'Now force PPT to go to the slide again (ie, to redraw it) so that 'the changed text appears: SlideShowWindows(1).View.GotoSlide (SlideShowWindows(1).View.Slide.SlideIndex) End Sub Function Random(High As Long) As Long 'Generates a random number less than or equal to 'the value passed in High Randomize Random = Int((High * Rnd) + 1) End Function



Reply With Quote
.
