有时,您可能希望通过随机随机播放幻灯片来为PowerPoint演示文稿添加惊喜元素。例如,也许您为学生创建了一个演示文稿,并想要随机播放部分或全部抽认卡。

默认情况下,PowerPoint没有内置的功能,但您可以使用宏来实现。在本分步指南中,我们将向您展示如何手动随机播放幻灯片以及如何使用VBA代码自动执行随机随机播放过程。
如何在PowerPoint中(PowerPoint)手动随机播放幻灯片(Manually Shuffle Slides)
在Microsoft PowerPoint中,您可以使用“幻灯片排序器”视图手动打乱演示文稿中的幻灯片,以随机顺序显示它们。虽然此方法可能不像使用宏那样随机,但它仍然允许您以不同的顺序重新排列幻灯片。
要手动随机播放PowerPoint(PowerPoint)演示文稿中的幻灯片,请按照以下步骤操作。
- 打开PowerPoint演示文稿,然后转到屏幕顶部功能区菜单中的“查看”选项卡。(View)单击(Click)它可访问“查看”(View)菜单。

- 在“视图”(View)菜单中,查找“演示文稿视图”(Presentation Views)组,然后选择“幻灯片排序器”(Slide Sorter)选项。这会将您的演示文稿切换到“幻灯片排序器”(Slide Sorter)视图,您可以在其中一次看到所有幻灯片缩略图。

- 在“幻灯片排序器”(Slide Sorter)视图中,您可能会看到更大的幻灯片缩略图。如果演示文稿中有很多幻灯片,请单击底部工具栏上的 - 图标表示的“缩小”选项,以更好地概览所有幻灯片。(Zoom Out)继续单击它,直到您可以在屏幕上同时看到演示文稿中的所有幻灯片。
- 现在,您可以通过单击幻灯片并将其拖动到屏幕上的随机位置来轻松地随机播放幻灯片。对其他幻灯片重复此步骤以随机打乱它们。继续重新排列幻灯片,直到您对新顺序感到满意为止。

请记住,此方法不能保证完全随机的顺序,因为它取决于您的手动安排。如果您希望在按下显示下一张幻灯片的按钮后看到完全随机的幻灯片,您可以使用VBA宏方法进行更精确和自动的随机洗牌。
如何使用VBA 代码随机化(VBA Code)PowerPoint 幻灯片(PowerPoint Slides)
为了确保您的 PowerPoint 幻灯片以完全随机的顺序播放,您需要使用一些编码。Microsoft Office PowerPoint中的宏(Macros)选项允许您运行VBA代码来自动随机播放演示文稿中的幻灯片。
在本教程中,我们将向您展示如何无重复地随机播放幻灯片。要在PowerPoint(PowerPoint)中随机化幻灯片以使同一张幻灯片不会重复,请按照以下步骤操作。
- 首先,您需要访问PowerPoint功能区菜单上的“开发人员”(Developer)选项卡。为此,请遵循路径“文件”(File) > “选项”(Options)或右键单击功能区菜单中的任何空白区域,然后选择“自定义(Customize)功能区(Ribbon)” 。这将打开一个对话框。

- 在“PowerPoint 选项”(Options)对话框中,向下滚动直至找到“开发人员”(Developer)选项。选中“开发人员”(Developer)旁边的框,然后单击“确定”。

- 现在选择“开发人员”(Developer)选项卡并选择“宏”(Macros)。在弹出窗口中,您可以插入新的宏(Macro)。为其选择一个名称(例如,Shuffleslides),然后单击“创建”(Create)继续。

- 这将打开Visual Basic 编辑器(Visual Basic Editor)窗口,您可以在其中输入代码以随机化PowerPoint演示文稿幻灯片。

- 复制以下VBA代码并将其粘贴到打开的Visual Basic窗口中。
子随机播放幻灯片()
第一张幻灯片 = 2
最后一张幻灯片 = 5
随机化
“在第一张幻灯片和最后一张幻灯片之间生成一个随机的否”
GRN:
RSN = Int (( LastSlide – FirstSlide + 1 ) * Rnd + FirstSlide )
如果RSN = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex则转到 GRN(GoTo GRN)
ActivePresentation.SlideShowWindow.View.GotoSlide ( RSN )
结束子
- 粘贴代码后,您会注意到默认设置会随机播放幻灯片 2 到 5。但是,您的演示文稿可能没有正好五张幻灯片,但这没有问题。您可以轻松自定义这部分代码以满足您的需求。
在VBA 编辑器(VBA Editor)中,调整“FirstSlide”和“LastSlide”后面的幻灯片编号,以指定要包含在随机播放中的幻灯片范围。默认情况下,随机播放从幻灯片 2 开始,以避免包含标题幻灯片。如果您希望将标题幻灯片排除在随机播放之外,请保持“FirstSlide = 2”不变。
例如,假设您有一个包含十张幻灯片的演示文稿,并且您想跳过标题幻灯片的混排。在这种情况下,设置“FirstSlide = 2”和“LastSlide = 10”。这样,只有幻灯片 2 到 10 会包含在随机播放过程中,并且您的标题幻灯片将不受影响。
- 现在您已经完成并自定义了演示文稿的代码,是时候向幻灯片添加操作按钮了。(add action buttons)为此,请在第一张幻灯片(或您喜欢的任何幻灯片)上插入任何形状,然后选择该形状并导航到“Insert > Action > Run Macro。然后选择您刚刚创建的宏。(Macro)这将在幻灯片放映模式(Slide Show Mode)期间激活幻灯片的随机播放,为观众提供引人入胜的体验。

- (Save your PowerPoint file)以PPTM格式(启用宏的演示文稿)保存 PowerPoint 文件以保留您创建的宏。(Macros)Select File > Save As ,然后从下拉列表中
选择PPTM ,以确保您创建的宏将被保留且不会丢失。(PPTM)

现在进入演示模式(Presentation Mode)并单击第一张幻灯片上的按钮随机播放幻灯片。享受您动态且非重复的演示。
如何仅随机播放(Shuffle)偶数或奇数幻灯片(Odd Slides)
如果您只想随机播放演示文稿中的特定幻灯片(例如偶数或奇数幻灯片),则可以使用以下VBA代码仅随机化偶数或奇数幻灯片,而不会干扰其余幻灯片。
为此,请按照上面的步骤操作,直到进入Visual Basic 编辑器(Visual Basic Editor)窗口并插入以下代码。
子随机播放幻灯片()
EvenShuffle = True(如果仅随机播放奇数幻灯片,则替换为 false)
FirstSlide = 2(根据需要应为偶数/奇数)
最后一张幻灯片 = 8
随机化
对于 i = FirstSlide到最后一张幻灯片步骤 2(LastSlide Step 2)
生成:“在第一张幻灯片和最后一张幻灯片之间生成一个随机编号”
RSN = Int (( LastSlide – FirstSlide + 1 ) * Rnd ) + FirstSlide
如果 EvenShuffle = True 那么
如果RSN Mod 2 = 1 则转到(GoTo)生成
别的
如果RSN Mod 2 = 0 则转到(GoTo)生成
万一
ActivePresentation.Slides (i).MoveTo ( RSN )
如果 i < RSN则ActivePresentation.Slides ( RSN – 1 ).MoveTo (i)
如果 i > RSN则ActivePresentation.Slides ( RSN + 1 ).MoveTo (i)
接下来我
结束子
如何以永无休止的循环方式
随机播放幻灯片(Slides)
上面的教程演示了如何随机播放PowerPoint幻灯片并以随机顺序播放它们而不重复。但是,在一次循环之后,除非您再次随机播放幻灯片,否则将保持相同的随机播放顺序。
要在幻灯片放映模式下自动循环播放所有幻灯片,并为每个循环提供新的随机顺序,您可以使用以下代码。请务必更改(Make)FirstSlide =和LastSlide =之后的数字,以适合演示文稿中的幻灯片数量。
公共位置(Public Position)、范围(Range)、AllSlides () As Integer
子 ShuffleAndBegin()
第一张幻灯片 = 2
最后一张幻灯片 = 6
范围 = (最后一张幻灯片 – 第一张幻灯片)
重新调暗所有幻灯片(0 至范围)
对于 i = 0 至范围
所有幻灯片(i) = 第一张幻灯片 + i
接下来我
随机化
对于 N = 0 至范围
J = Int((范围 + 1) * Rnd)
温度 = 所有幻灯片(N)
所有幻灯片(N) = 所有幻灯片(J)
所有幻灯片(J) = 温度
下一个 N
位置 = 0
ActivePresentation.SlideShowWindow.View.GotoSlide AllSlides(位置(Position))
结束子
子预付款()
位置 = 位置 + 1
如果位置 > 范围,则
随机播放并开始
别的
ActivePresentation.SlideShowWindow.View.GotoSlide AllSlides(位置(Position))
万一
结束子
是时候开始你的演讲了
现在您知道如何像专业人士一样随机播放PowerPoint幻灯片了。(PowerPoint)尝试这些方法,为教育工作者、商业专业人士或任何需要随机幻灯片顺序的场景创建引人入胜的演示文稿。(create engaging presentations)享受充满活力和迷人的幻灯片的乐趣。
How to Randomize Slides in PowerPoint Presentation
Sometimes, you may want to add an element of surprise to yoυr PowerPoint presеntаtion by shuffling the slides randomly. For example, perhaps you create a prеsentation for your ѕtudents and want to shufflе some or all of thе flashсards.

By default, PowerPoint doesn’t have a built-in feature for this, but you can achieve it using a macro. In this step-by-step guide, we’ll show you how to shuffle slides manually and how to use a VBA code to automate the random shuffling process.
How to Manually Shuffle Slides in PowerPoint
In Microsoft PowerPoint, you can manually shuffle the slides in your presentation to display them in random order using the “Slide Sorter” view. While this method may not be as random as using macros, it still allows you to rearrange the slides in a different order.
To manually shuffle and randomize the slides in a PowerPoint presentation, follow the steps below.
- Open your PowerPoint presentation and go to the View tab in the ribbon menu at the top of the screen. Click on it to access the View menu.

- In the View menu, look for the Presentation Views group, and select the Slide Sorter option. This will switch your presentation to the Slide Sorter view, where you can see all the slide thumbnails at once.

- In the Slide Sorter view, you may see larger thumbnails of the slides. If you have a lot of slides in your presentation, click on the Zoom Out option represented by the – icon at the bottom toolbar to get a better overview of all the slides. Keep clicking on it until you can see all the slides in the presentation on the screen at once.
- Now, you can easily shuffle the slides by clicking on a slide and dragging it to a random position on the screen. Repeat this step with other slides to shuffle them randomly. Continue rearranging the slides until you are satisfied with the new order.

Keep in mind that this method doesn’t guarantee a completely random order, as it depends on your manual arrangement. If you want to see a completely random slide appear after you hit the button to show the next slide, you can use the VBA macros method for more precise and automated random shuffling.
How to Randomize PowerPoint Slides Using a VBA Code
To make sure your PowerPoint slides are playing in completely random order, you’ll need to use a little bit of coding. The Macros option in Microsoft Office PowerPoint allows you to run VBA codes to automatically shuffle the slides in your presentation.
In this tutorial, we’ll show you how to shuffle your slides with no duplicates. To randomize slides in PowerPoint so that the same slide doesn’t repeat itself, follow the steps below.
- To get started, you’ll need to access the Developer tab on your PowerPoint ribbon menu. To do that, follow the path File > Options or right-click in any empty space in the ribbon menu and select Customize the Ribbon. This will open a dialog box.

- In the PowerPoint Options dialog box, scroll down until you find the Developer option. Check the box next to Developer and click OK.

- Now select the Developer tab and choose Macros. In the pop-up window, you can insert a new Macro. Choose a name for it (for example, Shuffleslides) and click Create to continue.

- This will open the Visual Basic Editor window, where you can input the code to randomize your PowerPoint presentation slides.

- Copy the following VBA code and paste it into the open Visual Basic window.
Sub Shuffleslides()
FirstSlide = 2
LastSlide = 5
Randomize
‘generate a random no between first slide and last slide’
GRN:
RSN = Int((LastSlide – FirstSlide + 1) * Rnd + FirstSlide)
If RSN = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex Then GoTo GRN
ActivePresentation.SlideShowWindow.View.GotoSlide (RSN)
End Sub
- After pasting the code, you’ll notice that the default setting shuffles slides 2 through 5. However, your presentation may not have exactly five slides, but that’s no problem. You can easily customize this part of the code to suit your needs.
In the VBA Editor, adjust the slide numbers following “FirstSlide” and “LastSlide” to specify the range of slides you want to include in the shuffle. By default, the shuffling starts from slide 2 to avoid including the title slide. If you wish to exclude the title slides from shuffling, keep “FirstSlide = 2” as it is.
For instance, let’s say you have a presentation with ten slides, and you want to skip shuffling the title slide. In that case, set “FirstSlide = 2” and “LastSlide = 10”. This way only slides 2 to 10 will be included in the shuffling process, and your title slide will remain unaffected.
- Now that you have completed and customized the code for your presentation, it’s time to add action buttons to the slides. To do that, insert any shape on the first slide (or any slide you prefer), then select the shape and navigate to Insert > Action > Run Macro. Then choose the Macro you just created. This will activate the shuffling of your slides during the Slide Show Mode, providing an engaging experience for your audience.

- Save your PowerPoint file in a PPTM format (Macro-enabled presentation) to retain the Macros you created. Select File > Save As and choose PPTM from the drop-down list to ensure that the macros you’ve created will be preserved and not lost.

Now enter the Presentation Mode and click the button on the first slide to shuffle your slides randomly. Enjoy your dynamic and non-repeating presentation.
How to Shuffle Only Even or Odd Slides
In case you want to shuffle only specific slides in your presentation, like even or odd slides, you can use the following VBA code to only randomize even-numbered or odd-numbered slides without disturbing the rest.
To do that, follow the steps from above until you get to the Visual Basic Editor window and insert the following code.
Sub Shuffleslides()
EvenShuffle = True (replace with false if only odd-numbered slides are shuffled)
FirstSlide = 2 (should be an even/odd number based on needs)
LastSlide = 8
Randomize
For i = FirstSlide To LastSlide Step 2
Generate: ‘generate a random no between first slide and last slide’
RSN = Int((LastSlide – FirstSlide + 1) * Rnd) + FirstSlide
If EvenShuffle = True Then
If RSN Mod 2 = 1 Then GoTo generate
Else
If RSN Mod 2 = 0 Then GoTo generate
End If
ActivePresentation.Slides(i).MoveTo (RSN)
If i < RSN Then ActivePresentation.Slides(RSN – 1).MoveTo (i)
If i > RSN Then ActivePresentation.Slides(RSN + 1).MoveTo (i)
Next i
End Sub
How to Shuffle Your Slides in a Never-Ending Loop
The tutorial above demonstrates how to shuffle PowerPoint slides and play them in a random order without repetition. However, after one loop, the same shuffled order is maintained unless you shuffle the slides again.
To automatically go through all the slides in an endless loop during slide-show mode with a new random order for each loop, you can use the following code. Make sure to change the numbers after FirstSlide = and LastSlide = to fit the number of slides in your presentation.
Public Position, Range, AllSlides() As Integer
Sub ShuffleAndBegin()
FirstSlide = 2
LastSlide = 6
Range = (LastSlide – FirstSlide)
ReDim AllSlides(0 To Range)
For i = 0 To Range
AllSlides(i) = FirstSlide + i
Next i
Randomize
For N = 0 To Range
J = Int((Range + 1) * Rnd)
temp = AllSlides(N)
AllSlides(N) = AllSlides(J)
AllSlides(J) = temp
Next N
Position = 0
ActivePresentation.SlideShowWindow.View.GotoSlide AllSlides(Position)
End Sub
Sub Advance()
Position = Position + 1
If Position > Range Then
ShuffleAndBegin
Else
ActivePresentation.SlideShowWindow.View.GotoSlide AllSlides(Position)
End If
End Sub
Time to Start Your Presentation
Now you know how to shuffle PowerPoint slides like a pro. Experiment with these methods and create engaging presentations for educators, business professionals, or any scenario that requires a randomized slide order. Have fun with your dynamic and captivating slideshows.