Using VBA programs to make a random presentation of PPT slides

Source: Internet
Author: User

using VBA programs to make a random presentation of ppt slides

1. Launch PowerPoint 2013 and open the presentation, which has finished making the title page and adding the topic. Use the method described in Tip 429 to add a button control to the slide and change the control's "Caption" property value in the Properties panel, as shown in Figure 1.

Figure 1 Changing the value of the control's "Caption" property

2. Right-click the button control on the slide, select View Code on the shortcut menu, and enter the program code in the Code window of the open Visual Basic Editor, as shown in Figure 2. The specific program code is as follows.

Figure 2 Entering program code in the Code window

-Private Sub CommandButton1_Click ()

Dim I as integer,n as Integer ' define variable

I=int ((6*rnd) +1) ' Gets the random number between 1~6

Randomize ' initialization random number

I=int ((6*rnd) +1) ' Initialize the random number between 1~6 again after initialization

N=i+1 ' assigns value to variable N, which is the number of the slide

Modified with SlideShowWindows (1)

08.view.gotoslide N ' jump to a specified numbered slide

With

Ten End Sub

3, copy the button in the title page, paste it into slide two, and then change the control's Caption property value in the Properties panel, as shown in Figure 3.

Figure 3 Copy button and set its "Caption" property

4. Right-click the button control on the slide and select "View Code" from the shortcut menu. In the code window of the open Visual Basic Editor, add the Click event Responder for the button, as shown in Figure 4. The specific program code is as follows.

Figure 4 Adding the Click event Responder for the button

-Private Sub CommandButton1_Click ()

With SlideShowWindows (1)

03. View.gotoslide 1 ' jump to the first slide

With

End Sub

5, copy the button on the second slide to the slide that follows. After you add an event responder to these buttons in the same way as step ④, press the "F5" key to play the slide and click the "Quiz" button in the title page, as shown in Figure 5, where PowerPoint will randomly jump to a subsequent slide show topic , click the "Back to Home" button in the topic page, as shown in Figure 6, to skip to the topic page.

Figure 5 showing the topic page

Fig. 6 Random problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.