LoginSignup
9
8

More than 5 years have passed since last update.

パワポでズンドコキヨシ

Last updated at Posted at 2016-03-17

「ズン」と「ドコ」のスライドを追加していって、例のパターンが発生したら「キ・ヨ・シ!」で終わるスライドを自動で作ります。生成されたスライドはリズムに乗ってめくっていくなどすると盛り上がると思います。

  1. PowerPointのオプションのリボンの設定で「開発」リボンを有効にします
  2. 「開発」リボンの「Visual Basic」をクリックしてVisual Basic Editorを開きます
  3. Visual Basic Editor左側の「VBAProject」を右クリックして「挿入→標準モジュール」を選択します
  4. 作成されたモジュールの中に以下のコードをペーストします
  5. コード中のSub ZunDokoKiyosi()の行を選択してツールバーの実行ボタンを押します。
Sub ZunDokoKiyosi()
    Do While ActivePresentation.Slides.Count > 0
        ActivePresentation.Slides.Item(1).Delete
    Loop

    `パターン判定はC言語版のNLZ(number of leading ZUN)方式を拝借
    Dim nlz As Integer
    Dim c As Integer

    nlz = 0
    c = 0

    Do
        nlz = IIf(c = 1, nlz + 1, 0)
        c = Int(Rnd * 2)
        AddSlide IIf(c = 1, "ズン", "ドコ")
    Loop While nlz < 4 Or c = 1

    AddSlide "キ・ヨ・シ!"
End Sub

Function AddSlide(text As String)
    Dim p As Presentation
    Dim slide As slide
    Dim textBox As Shape

    Set p = ActivePresentation
    Set slide = p.Slides.Add(p.Slides.Count + 1, Layout:=ppLayoutBlank)

    Set textBox = slide.Shapes.AddTextbox(msoTextOrientationHorizontal, 0, 0, 0, 0)

    With textBox
        .TextFrame.TextRange = text
        .TextFrame.TextRange.ParagraphFormat.Alignment = ppAlignCenter
        .TextFrame.VerticalAnchor = msoAnchorMiddle
        .TextFrame.AutoSize = ppAutoSizeNone
        .Width = p.PageSetup.SlideWidth
        .Height = p.PageSetup.SlideHeight
        .TextEffect.FontSize = 200
    End With

    ActiveWindow.View.GotoSlide slide.SlideIndex
End Function

pp-zun-doko-kiyoshi.gif

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8