2017年3月15日水曜日

VBScript PowerPointのスライド枚数カウント

PowerPointファイルの総スライド枚数と非表示スライド枚数をカウント。

スライド枚数は、SlidesコレクションのCountプロパティで取得。
非表示かどうかはSlideShowTransition.Hiddenプロパティで取得できるので、それをforで回してカウント。

set objArgs = WScript.Arguments
If objArgs.Count = 0 then
WScript.Quit
End If
 
Set pptApp = CreateObject("PowerPoint.Application")
pptApp.Visible = True
 
Dim targetFile : targetFile = WScript.Arguments(0)
pptApp.Presentations.Open targetFile

With pptApp.ActivePresentation
 h = 0                   '非表示スライド枚数
 cnt = .Slides.Count     'スライド枚数
 
 For i = 1 To cnt
  With  .Slides(i)
   If .SlideShowTransition.Hidden = -1 Then
    h = h + 1
   End If
  End With
 Next
End With

MsgBox "総スライド枚数は" & cnt & "枚" & vbCrLf & "非表示スライドは " & h & "枚"

変数宣言は省略・・・。

0 件のコメント:

コメントを投稿