Current location - Recipe Complete Network - Complete cookbook of home-style dishes - How to realize random topic selection in ppt
How to realize random topic selection in ppt
As we all know, we can use formulas and machines to make a number in excel, but it can also be used in ppt. What should I do? The following is what I brought to you about the random selection of PPT, hoping to help you.

PPT realizes random topic selection

Design topic extraction interface

Open PPT20 10, and save the presentation in the PPT presentation format with macro enabled (i.e.. pptm format, and the presentation with macro code must be saved in this format). Design the topic selection interface of the first slide, insert three text boxes, write the necessary text, and then pass? Develop tools? Tab, insert three command button controls, right-click these controls, and then select? Attribute? Command, open them? Attribute? Dialog box, in? Name? Later, the name of the command button was changed to: start, stop, open the selected theme, and then fill in the name displayed on the button after Caption (it can be capitalized at will, just like the button name I set here), and set the font, font size, background color and style.

Insert three more text box controls, also in? Attribute? Dialog box, change their names to: extraction box, result box and extracted topic. Release? Extraction box? Release? Start? And then what? Stop? Between command button controls, place? Result box? Release? What number did you choose? In the text, replace? Have you drawn the topic? Drag it to the appropriate size and put it below (Figure 1).

Then create a new slide, design the selected theme placement interface, and design a link on it to return to the slide of the selected theme interface. Make multiple copies of this slide, enter the corresponding theme on the corresponding slide, the first theme is on the second slide, the second theme is on the third slide, and so on.

Write macro code

Next, press ALT+F 1 1 to open the VBA macro editing window, and double-click? Slide 1? , copy the following code into the right pane and save it.

Private child start _Click ()

Stop. The "Enabled = True" stop button is currently active.

Dim a as an integer.

Irregular

do

A = Fix(Rnd * 10+ 1)' uses a random function.

Select box. text = a

Result box. Text = ""

Multiple activities

ring

End joint

Private Sub stop _Click ()

Result box. Text = check box. text

Selected Topics = Selected Topics+Select Box+"#"' Topic labels are separated by #.

Stop. Enabled = False

end

End joint

Private Sub opens the selected topic _Click ().

ActivePresentation slide show window _

View.goto slideval (check box. Text+ 1)

End joint

Randomly select questions and open them.

After the theme is selected, play the slides and click the first one? Start? Button, and then the ten numbers from 1 to 10 will be displayed randomly and quickly in the text box below. Click? Stop? Button, the number stops scrolling, the extracted question number is displayed, and it is given at the top. Did you choose question X? Hint, below? Have you drawn the topic? All selected topic numbers are displayed in. Click below? Open the selected topic? Button to switch to the theme selection slide. After the player finishes the topic, click the back link to return to the topic selection page and continue to select the topic for the next player (Figure 2).

Tip: In the slide show state, you can select the text in three text box controls and delete them to achieve the purpose of clearing.

Code diagram

Macro code

Private child start _Click ()

Stop. The "Enabled = True" stop button is currently active.

Dim a as an integer.

Irregular

do

A = Fix(Rnd * 10+ 1)' uses a random function.

Select box. text = a

Result box. Text = ""

Multiple activities

ring

End joint

Private Sub stop _Click ()

Result box. Text = check box. text

Selected Topics = Selected Topics+Select Box+"#"' Topic labels are separated by #.

Stop. Enabled = False

end

End joint

Private Sub opens the selected topic _Click ().

ActivePresentation slide show window _

View.goto slideval (check box. Text+ 1)

End joint