ExcelのCommandBarオブジェクト一覧を作成するExcelマクロ、WordのCommandBarオブジェクト一覧を作成するExcelマクロをご紹介しました。
PowerPointの場合も見ておきましょう。
PowerPointのCommandBarオブジェクト一覧をExcelに出力するサンプルマクロ
以下のPowerPointマクロを実行すると、PowerPointのCommandBarオブジェクト一覧がExcelに出力されます。
Dim xl_app As Object, xl_bk As Object
Set xl_app = CreateObject("Excel.Application")
xl_app.Visible = True
Set xl_bk = xl_app.Workbooks.Add
Dim xl_sht As Object
Set xl_sht = xl_bk.Sheets(1)
xl_sht.Cells(1, "A").Value = "Index"
xl_sht.Cells(1, "B").Value = "Name"
xl_sht.Cells(1, "C").Value = "NameLocal"
Dim i As Long
With PowerPoint.Application.CommandBars
For i = 1 To .Count
xl_sht.Cells(i + 1, "A").Value = .Item(i).Index
xl_sht.Cells(i + 1, "B").Value = .Item(i).Name
xl_sht.Cells(i + 1, "C").Value = .Item(i).NameLocal
Next
End With
xl_sht.Range("A1:C1").Font.Bold = True
xl_sht.Columns("A:C").AutoFit
上記のPowerPointマクロは、WordのCommandBarオブジェクトをExcelに出力するWordマクロとやっていることは同じです。
For~Nextループに入る直前のWith文を、Wordの場合
With Word.Application.CommandBars
としていましたが、上記のPowerPointマクロでは
With PowerPoint.Application.CommandBars
としている点だけが異なります。
Home » パワーポイントマクロ・PowerPoint VBAの使い方 » PowerPointのCommandBarオブジェクト一覧をExcelに出力するマクロ