LoginSignup
1
2

More than 5 years have passed since last update.

PowerPointのスライドの右隅に総ページ数を挿入するVBScript

Last updated at Posted at 2019-03-22

スライド番号は出せるのに・・・ という、ネタ自体はよくある話。
最初はPowerPointのVBAマクロで作り始めたけど、
それより外出ししてVBScriptにしたほうが扱いやすいかなと思い、軌道修正。
スライドのページを追加・削除したら、最後に自分でこのスクリプトを走らせる感じで使っています。
位置や文字色やサイズは自分の環境にあわせて適当に変えてください。

InsertTotalNumberOfPagesToSlideMaster

Sub InsertTotalNumberOfPagesToSlideMaster()
    Const TNOP= "TotalNumberOfPages" 
    Set PPAP = GetObject(, "PowerPoint.Application").ActivePresentation

    With PPAP.SlideMaster
        For Each shp In .Shapes
            If shp.Name = TNOP Then Exit For
        Next
        If IsEmpty(shp) Then Set shp = .Shapes.AddTextbox(1, 0, 0, 10, 10)
        shp.Name = TNOP
        shp.TextFrame.TextRange.Text = "/" & PPAP.Slides.Count - 1
    End With

    With shp.TextFrame
        .WordWrap = 0
        .AutoSize = 1
        .MarginRight = 0
        With .TextRange.Font
            .Size = 9
            .Name = "Meiryo UI"
        End With
    End With

    With shp
        .Left = .Parent.Width - .Width
        .Top = .Parent.Height - .Height
    End With

End Sub
1
2
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
1
2