Powerpoint VBA Powerpointで一気に参照設定を設定するマクロ Set Reference Settings Into PowerPoint Quickly.

# 適用範囲 Apply
Powerpoint 2010 Later
2019でも変わらないです。
# 下準備
[excel Access VBA ２つか1つの設定でVBAの参照設定を完了するマクロ](https://qiita.com/Q11Q/items/67226e7c8b9def529668)
を参考に次のことを行います。
1.リボンに開発タグを表示
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/126919/56f63903-ff89-f9e4-735d-9e20deb2de33.png)

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/126919/31ad31ac-e487-0d4f-e41a-ddcac5f32d78.png)

2．ファイル>オプション>セキュリティセンターでセキュリティセンターでマクロの設定　すべてのマクロを有効 VBAオブジェクトモデルへのアクセスを信頼するにチェック
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/126919/a440dd96-0952-4c47-0f37-0c807fbf6c7f.png)

# コード

## Referenceの入り口がActiveVBProject
### 変な点
#### 入り口がActiveVBProject
確かに参照設定のリストを書き出す場合も、Powerpointはこれを使います。
しかし、VBAではこのような大本のところでActiveを使う例はあまりないと思います。あっても代替の方法があります（Current,Thisなど）。Powerpointは見つかりません。
[Application.VBE property (PowerPoint)](https://docs.microsoft.com/ja-jp/office/vba/api/powerpoint.application.vbe)
ここでもApplicationしか紹介しておらず、不親切極まりない。

[VBE プロパティ (Access)](https://docs.microsoft.com/ja-jp/office/vba/api/access.application.vbe)
>VBEオブジェクトへの参照を設定すると、そのオブジェクトのすべてのプロパティとメソッドにアクセスできるようになります。 モジュールのデザインビューで [ツール] メニューの [参照設定] を選択すると、 VBEオブジェクトへの参照を設定できます。 [参照設定] ダイアログボックスで適切なチェックボックスをオンにして、Microsoft Visual Basic for Applications の機能拡張5.3 オブジェクトライブラリへの参照を設定できます。

このアクセスの解説が、PowerPointにも有効です。最も書き方は全然違いますが。
またActiveVBProjectはExcelでも見られます。
http://officetanaka.net/excel/vba/vbe/
しかしここから行くサンプルでもわかるようにActiveWorkbook.VBProjectはThisworkbook.VBProjectに置換できます。
またサンプルと比較すると
http://officetanaka.net/excel/vba/vbe/02.htm
このオブジェクト構造だと
VBEとVBProjectの間にWorkbookがあることになります。Excelのほうが変わっているわけですが、Excelがメジャーすぎるため、PowerPointが変に見えてしまいます。ExcelもApplication.VBEという記述はできるのですが、ほぼ使われないでしょう。田中先生の影響です。

#### 変数がVariantしかない
VBIDE,{0002E157-0000-0000-C000-000000000046},5,3,Microsoft Visual Basic for Applications Extensibility 5.3,C:\Program Files (x86)\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB,0
これに参照設定を入れているという前提ですが、
通常は
`Dim ref As Reference, refs as References`
というのを使いますが、Powerpointは出てきません。
また、Variantで設定しても効かないときがあります。
そこで、
With PowerPoint.Application.VBE.ActiveVBProject.References
というのを多用しました。
変数が効かないので、Withで省略しているだけになります。

#### 設定してる状態ではRefは有効
[VBA Powerpointの参照設定をイミディエイトに出力する Wordはファイルに出力する Powerpoint And WinWord Export Reference Settings](https://qiita.com/Q11Q/items/5c98e74a2c9122b485ca)
通常はPowerpointでも参照設定をしている状態であればref,refsは成功しています。
しかし、この場合はイミディエイトには出力できるのですが、テキストストリームには効きませんでした。
随分と挙動がおかしいのですが、どうなんでしょうね。とりあえずPowerpointの参照設定なんて普通はしないはずです。そもそもVBAすらあまり使われないでしょう。ただ、テキストのみ出力すると言うのが、Powerpointにはよく考えるとありません。rtfも1ページづつで実用に堪えるものではありません。しかし、Wordにテキストボックスの中身を出力するのは有効です。そんなわけで、これが見つかりました。

```vb
Sub PowerPointAddReferenceSetting()
On Error GoTo ERR_HANDLE
PowerPoint.Application.VBE.ActiveVBProject.References.AddFromGuid "{0002E157-0000-0000-C000-000000000046}", 5, 3
Call PowerPointAddReferenceSetting2
Exit Sub
ERR_HANDLE:
Call PowerPointAddReferenceSetting2
End Sub
Private Sub PowerPointAddReferenceSetting2()
On Error Resume Next
Const GUID_GRAPH = "{00020802-0000-0000-C000-000000000046}"
Const GUID_ADOR = "{00000300-0000-0010-8000-00AA006D2EA4}"
Const GUID_OfficeObject = "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}"
Const GUID_WinWord = "{00020905-0000-0000-C000-000000000046}" ' Microsoft Word 16.0 Object Library= 8.7
Const GUID_MSPub = "{0002123C-0000-0000-C000-000000000046}"      'Microsoft Publisher 16.0 Object Library   = 2.3
Const GUID_OUTLOOK = "{0006F062-0000-0000-C000-000000000046}" ' Microsoft Outlook 16.0 Object Library 9.6
Const GUID_OLXLib = "{0006F062-0000-0000-C000-000000000046}" ' Microsoft Outlook View Control = 1.2
Const GUID_POWERPOINT = "{91493440-5A91-11CF-8700-00AA0060263B}" ' Microsoft PowerPoint 16.0 Object Library = 2.12
Const GUID_Excel = "{00020813-0000-0000-C000-000000000046}"  ' Microsoft Excel 16.0 Object Library  = 1.9

' For Microsoft Excel 2010 Later Beta Version
'PowerPoint.Application.VBE.ActiveVBProject.References.AddFromGuid "{4AC9E1DA-5BAD-4AC7-86E3-24F4CDCECA28}", 12, 0 'DAO, 12, 0  ' Microsoft Office 16.0 Access database engine Object Library  =12.0 Note: You need download and  Install
With PowerPoint.Application.VBE.ActiveVBProject.References
.AddFromGuid "{B691E011-1797-432E-907A-4D8C69339129}", 6, 1 'ADODB, 6, 1  'Microsoft ActiveX Data Objects 6.1 Library =6.1
.AddFromGuid "{00000600-0000-0010-8000-00AA006D2EA4}", 6, 0  'Microsoft ADO Ext. 6.0 for DDL and Security  =6.0
.AddFromGuid "{00000300-0000-0010-8000-00AA006D2EA4}", 6, 0 'Microsoft ActiveX Data Objects Recordset 6.0 Library
.AddFromGuid "{4AFFC9A0-5F99-101B-AF4E-00AA003F0F07}", 9, 0   'Microsoft Access XX.0 Object Library
.AddFromGuid "{CD000000-8B95-11D1-82DB-00C04FB1625D}", 1, 0 'Microsoft CDO for Windows 2000 Library = 1.0
.AddFromGuid "{5477469E-83B1-11D2-8B49-00A0C9B7C9C4}", 2, 4  'Common Language Runtime Execution Engine 2.4 Library  = 2.4
.AddFromGuid "{2735412F-7F64-5B0F-8F00-5D77AFBE261E}", 1, 0 'Microsoft IMAPI2 Base Functionality = 1.0
.AddFromGuid "{2C941FD0-975B-59BE-A960-9A2A262853A5}", 1, 0 'Microsoft IMAPI2 File System Image Creator  = 1.0
.AddFromGuid "{2358C810-62BA-11D1-B3DB-00600832C573}", 4, 0  'JET Expression Service Type Library
.AddFromGuid "{AC3B8B4C-B6CA-11D1-9F31-00C04FC29D52}", 2, 6  ' Microsoft Jet and Replication Objects 2.6 Library =  2.6       C:\Program Files (x86)\Common Files\System\ado\msjro.dll
.AddFromGuid "{76F6F3F5-9937-11D2-93BB-00105A994D2C}", 1, 0 'Microsoft Office Euro Converter Object Library = 1.0"
.AddFromGuid "{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}", 4, 0  'Microsoft HTML Object Library  = 4.0     C:\Windows\SysWOW64\msjtes40.dll 4.0"
.AddFromGuid "{F5078F18-C551-11D3-89B9-0000F81FE221}", 6, 0   ' Microsoft XML, v6.0         C:\Windows\System32\msxml6.dll = 6.0
.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 16, 0 'Microsoft Office 16.0 Object Library      C:\Program Files\Common Files\Microsoft Shared\OFFICE16\MSO.DLL = 2.8
.AddFromGuid "{F618C513-DFB8-11D1-A2CF-00805FC79235}", 1, 0
.AddFromGuid "{8E80422B-CAC4-472B-B272-9635F1DFEF3B}", 1, 0  'MMC20  Microsoft Management Console 2.0
.AddFromGuid "{3F4DACA7-160D-11D2-A8E9-00104B365C9F}", 5, 5 'Microsoft VBScript Regular Expressions 5.5
.AddFromGuid "{420B2830-E718-11CF-893D-00A0C9054228}", 1, 0 ' Microsoft Scripting Runtime C:\Windows\System32\scrrun.dll =  1.0
.AddFromGuid "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", 1, 0  ' Microsoft Shell Controls And Automation  = 1.0
.AddFromGuid "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 1, 1   'Microsoft Internet Controls = 1.1
.AddFromGuid "{94A0E92D-43C0-494E-AC29-FD45948A5221}", 1, 0          ' Microsoft Windows Image Acquisition Library v2.0   = 1.0
.AddFromGuid "{662901FC-6951-4854-9EB2-D9A2570F2B2E}", 5, 1 'Microsoft WinHTTP Services, version 5.1   C:\WINDOWS\system32\winhttpcom.dll = 5.1
.AddFromGuid "{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}", 1, 0  ' Windows Script Host Object Model  = 1.0
.AddFromGuid "{563DC060-B09A-11D2-A24D-00104BD35090}", 1, 0     ' WSHControler Library = 1.0
'Const GUID_RDS = "{BD96C556-65A3-11D0-983A-00C04FC29E30}": refs.AddFromGuid GUID_RDS, 1, 5       ' Microsoft Remote Data Services 6.0 Library  = 1.5
.AddFromGuid "{C866CA3A-32F7-11D2-9602-00C04F8EE628}", 5, 4  ' Microsoft Speech Object Library  =5.4"
.AddFromGuid "{EB2114C0-CB02-467A-AE4D-2ED171F05E6A}", 10, 0 ' Microsoft TTS Engine 10.0 Type Library =10.0
.AddFromGuid "{D37E2A3E-8545-3A39-9F4F-31827C9124AB}", 2, 4           'System.Drawing.dll  2.4
.AddFromGuid "{4FB2D46F-EFC8-4643-BCD0-6E5BFA6A174C}", 2, 4  'System_EnterpriseServices = 2.4
.AddFromGuid "{215D64D2-031C-33C7-96E3-61794CD1EE61}", 2, 0  'System Windows Forms 2.0 Object Library = 2.0
.AddFromGuid "{565783C6-CB41-11D1-8B02-00600806D9B6}", 1, 2  ' Microsoft WMI Scripting V1.2 Library  = 1.2
.AddFromGuid "{6BF52A50-394A-11D3-B153-00C04F79FAA6}", 1, 0        ' Windows Media Player = 1.0
.AddFromGuid "{00020905-0000-0000-C000-000000000046}", 8, 7 ' Microsoft Word 16.0 Object Library= 8.7
.AddFromGuid "{0006F062-0000-0000-C000-000000000046}", 9, 6 ' Microsoft Outlook 16.0 Object Library 9.6
.AddFromGuid "{0006F062-0000-0000-C000-000000000046}", 1, 2 ' Microsoft Outlook View Control = 1.2
'Const GUID_POWERPOINT = "{91493440-5A91-11CF-8700-00AA0060263B}" ' Microsoft PowerPoint 16.0 Object Library = 2.12
.AddFromGuid "{00020813-0000-0000-C000-000000000046}", 1, 9 ' Microsoft Excel 16.0 Object Library  = 1.9
.AddFromGuid "{00020802-0000-0000-C000-000000000046}", 1, 9 'Microsoft Graph 16.0 Object Library  = 1.9tr
.AddFromGuid "{4AFFC9A0-5F99-101B-AF4E-00AA003F0F07}", 9, 0 ' Microsoft Access 16.0 Object Library = 9.0
.AddFromGuid "{D9347025-9612-11D1-9D75-00C04FCC8CDC}", 1, 0 ' Microsoft Access BarCode Control 14.0  = 1.0
.AddFromGuid "{113D61B1-C7C0-4157-B694-43594E25DF45}", 1, 2 'eawfctrl 1.2 Type Library = 1.2
.AddFromGuid "{714DD4F6-7676-4BDE-925A-C2FEC2073F36}", 1, 0  ' AccessibilityCplAdminLib  AccessibilityCplAdmin 1.0 Type Library
.AddFromGuid "{21D6D480-A88B-11D0-83DD-00AA003CCABD}", 1, 0 ' TAPI3Lib  Microsoft TAPI 3.0 Type Library
.AddFromGuid "{44EC0535-400F-11D0-9DCD-00A0C90391D3}", 1, 0  ' ATLLib    ATL 2.0 Type Library
.AddFromGuid "{4AFFC9A0-5F99-101B-AF4E-00AA003F0F07}", 9, 0 ' Microsoft Access 14.0 -  16.0 Object Library
.AddFromGuid "{0E59F1D2-1FBE-11D0-8FF2-00A0D10038BC}", 1, 0  ' MSScriptControl  Microsoft Script Control 1.0
.AddFromGuid "{8D763331-F59C-46F5-99FF-F74CDC84AD0E}", 1, 0  ' Microsoft Project Task Launch Control
.AddFromGuid "{54AF9343-1923-11D3-9CA4-00C04F72C514}", 2, 50  'MACVer
.AddFromGuid "{0D452EE1-E08F-101A-852E-02608C4D0BB4}", 2, 0  ' Microsoft Forms 2.0 Object Library
.AddFromGuid "{7988B57C-EC89-11CF-9C00-00AA00A14F56}", 1, 0  ' Microsoft Disk Quota
.AddFromGuid "{06290C00-48AA-11D2-8432-006008C3FBFC}", 1, 0  ' Scriptlet
.AddFromGuid "{EB2114C0-CB02-467A-AE4D-2ED171F05E6A}", 10, 0  'Microsoft TTS Engine 10.0 Type Library
.AddFromGuid "{9B085638-018E-11D3-9D8E-00C04F72D980}", 1, 0  ' Microsoft Tuner 1.0
.AddFromGuid "{9B7C3E2E-25D5-4898-9D85-71CEA8B2B6DD}", 2, 0  ' FDATELib   FDate 2.0 Type Library      C:\Program Files\Common Files\Microsoft Shared\Smart Tag\FDATE.DLL
.AddFromGuid "{2206CEB0-19C1-11D1-89E0-00C04FD7A829}", 1, 0  ' MSDASC Microsoft OLE DB Service Component 1.0 Type Library
.AddFromGuid "{E0E270C2-C0BE-11D0-8FE4-00A0C90A6341}", 1, 5  ' MSDAOSP Microsoft OLE DB Simple Provider 1.5 Library
.AddFromGuid "{833E4000-AFF7-4AC3-AAC2-9F24C1457BCE}", 1, 0  ' HelpServiceTypeLib
.AddFromGuid "{2A005C00-A5DE-11CF-9E66-00AA00A3F464}", 1, 0  ' COMSVCSLib    COM+ Services Type Library
.AddFromGuid "{98315905-7BE5-11D2-ADC1-00A02463D6E7}", 1, 0  ' COMReplLib    ComPlus 1.0 Catalog Replication Type Library
.AddFromGuid "{6CAAAA3B-6502-40FE-97FC-72A290DC63CF}", 1, 0  ' CorrEngineLib CorrEngine 1.0 Type Library
.AddFromGuid "{87099223-C7AF-11D0-B225-00C04FB6C2F5}", 1, 0  ' FAXCOMLib   faxcom 1.0 Type Library
.AddFromGuid "{E4DE3030-0142-4ACA-BA48-8613B56A2555}", 1, 0 ' FAXCONTROLLib FaxControl 1.0 Type Library
.AddFromGuid "{2BF34C1A-8CAC-419F-8547-32FDF6505DB8}", 1, 0 ' Microsoft Fax Service Extended COM Type Library"
.AddFromGuid "{9CDCD9C9-BC40-41C6-89C5-230466DB0BD0}", 2, 0  ' Feed 2.0
.AddFromGuid "{0FFF9602-69CF-4728-9EA4-141514866CA2}", 1, 0 ' FIndPrinterslib
.AddFromGuid "{D8DC76AB-F007-49C6-B6FC-8392A3DF90C4}", 1, 0  ' LocalService 1.0 Type Library
.AddFromGuid "{BED7F4EA-1A96-11D2-8F08-00A0C9A6186D}", 2, 4  ' Microsoft Common Language Runtime Class Library System.Collection Arraylist
.AddFromGuid "{78530B68-61F9-11D2-8CAD-00A024580902}", 1, 0  ' DexterLib     Dexter 1.0 Type Library
.AddFromGuid "{9B085638-018E-11D3-9D8E-00C04F72D980}", 1, 0  ' ATLLib        ATL 2.0 Type Library
.AddFromGuid "{B30CDC65-4456-4FAA-93E3-F8A79E21891C}", 1, 0 ' ATLEntityPickerLib          ATLEntityPicker 1.0 Type Library
.AddFromGuid "{28854DE7-2CF8-4A60-A85A-C21184D76BB6}", 1, 0  ' InstallerMainShellLib       Installer Main Shell Lib
.AddFromGuid "{E34CB9F1-C7F7-424C-BE29-027DCC09363A}", 1, 0 ' TaskScheduler  1.0
.AddFromGuid "{28DCD85B-ACA4-11D0-A028-00AA00B605A4}", 1, 0 ' TERMMGRLib    TAPI3 Terminal Manager 1.0 Type Library
.AddFromGuid "{28DCD85B-ACA4-11D0-A028-00AA00B605A4}", 1, 1 ' TDCLib        Tabular Data Control 1.1 Type Library
.AddFromGuid "{8628F27C-64A2-4ED6-906B-E6155314C16A}", 1, 0 ' REMOTEPROXY6432Lib          RemoteProxy6432 1.0 Type Library
.AddFromGuid "{A87F050D-3FFD-4682-8E77-34E530624CB4}", 1, 0 ' SessionMsgLib
.AddFromGuid "{C3A407A9-3409-4028-ACCF-9225FD9688D7}", 1, 0 ' RdpCoreTSLib  Rdp Protocol Provider 1.0 Type Library
.AddFromGuid "{438EDB38-282C-435D-8BE3-4AB90B83CEF5}", 1, 0 ' PrintUIObjLib PrintUI Objects 1.0 Type Library
.AddFromGuid "{91CE54EE-C67C-4B46-A4FF-99416F27A8BF}", 1, 0 ' PrinterExtensionLib         Printer Extension 1.0 Type Library
.AddFromGuid "{C8B522D5-5CF3-11CE-ADE5-00AA0044773D}", 1, 0 ' OLEDBError      Microsoft OLE DB Error Library
.AddFromGuid "{FC5988CF-6D6A-4812-ADD9-2DDE4F47346F}", 1, 0 ' MSTSWebProxyLib Microsoft Terminal Services Web Proxy 1.0 Type Library
.AddFromGuid "{8C11EFA1-92C3-11D1-BC1E-00C04FA31489}", 1, 0 ' MSTSCLib        Microsoft Terminal Services Control Type Library
.AddFromGuid "{7E8BC440-AEFF-11D1-89C2-00C04FB6BFC4}", 1, 0 ' IEXTagLib       iextag 1.0 Type Library
.AddFromGuid "{06CA6721-CB57-449E-8097-E65B9F543A1A}", 1, 0 ' IETAGLib        ietag 1.0 Type Library
.AddFromGuid "{833E4000-AFF7-4AC3-AAC2-9F24C1457BCE}", 1, 0 ' HelpServiceTypeLib          Help Service 1.0 Type Library
.AddFromGuid "{BA35B84E-A623-471B-8B09-6D72DD072F25}", 1, 0 ' VisioViewer     Microsoft Visio Viewer 16.0 Type Library
.AddFromGuid "{B9164592-D558-4EE7-8B41-F1C9F66D683A}", 1, 0 ' OneNoteIEAddin  Microsoft OneNote IE Addin Object Library
.AddFromGuid "{1C82EAD8-508E-11D1-8DCF-00C04FB951F9}", 1, 0 ' MIMEEDIT        Microsoft MIMEEDIT Type Library 1.0
.AddFromGuid "{31411197-A502-11D2-BBCA-00C04F8EC294}", 1, 0 ' MSHelpServices  Microsoft Help Data Services 1.0 Type Library
.AddFromGuid "{F618C513-DFB8-11D1-A2CF-00805FC79235}", 1, 0 ' COMAdmin        COM + 1.0 Admin Type Library

#If Win32 Then
.AddFromGuid "{0109E0F4-91AE-4736-A2CE-9D63E89D0EF6}", 1, 0 'XPS_SHL_DLLLib XPS_SHL_DLL 1.0 Type Library 32 bit版のみ参照設定可能
#End If
End With
With PowerPoint.Application.VBE.ActiveVBProject.References
If Application.Version >= 16 Then
.AddFromGuid GUID_OfficeObject, 2, 8
.AddFromGuid GUID_Excel, 1, 9
.AddFromGuid "{00062FFF-0000-0000-C000-000000000046}", 9, 6 'Microsoft Outlook 16.0 Object Library
.AddFromGuid GUID_POWERPOINT, 2, 12
.AddFromGuid GUID_MSPub, 2, 3
.AddFromGuid GUID_OLXLib, 1, 2

.AddFromGuid "{113D61B1-C7C0-4157-B694-43594E25DF45}", 1, 2 'eawfctrl 1.0 Type Library
.AddFromGuid "{E301A065-3DF5-4378-A829-57B1EA986631}", 1, 0 ' Microsoft Outlook SharePoint Social Provider
.AddFromGuid "{3120BA9F-4FC8-4A4F-AE1E-02114F421D0A}", 1, 0 'OneNoteEx     Microsoft OneNote 15.0 Extended Object Library
.AddFromGuid "{E301A065-3DF5-4378-A829-57B1EA986631}", 1, 1 'Microsoft Outlook SharePoint Social Provider 1.1
.AddFromGuid "{1F8E79BA-9268-4889-ADF3-6D2AABB3C32C}", 1, 1 'OutlookSocialProvider       Microsoft Outlook Social Provider Extensibility
.AddFromGuid "{9E175B61-F52A-11D8-B9A5-505054503030}", 1, 0 'Microsoft Search Interface Type Library(from 2016)   C:\WINDOWS\system32\mssitlb.dll
.AddFromGuid "{CBBC4772-C9A4-4FE8-B34B-5EFBD68F8E27}", 1, 0 'NoteLinkComLib 1.0 Type Library(from 2016)
.AddFromGuid "{3120BA9F-4FC8-4A4F-AE1E-02114F421D0A} ", 1, 0 'Microsoft OneNote 15.0 Extended Object Library 1.0
.AddFromGuid GUID_WinWord, 8, 7 'Microsoft Word 16.0 Object Library
.AddFromGuid "{73720012-33A0-11E4-9B9A-00155D152105}", 1, 0 ' Microsoft Office Screen Recorder 16.0)from 2016) Object Librar
.AddFromGuid "{6CC6A20E-96A4-4F94-A838-8E5EBE9E9925}", 1, 0 ' ScreenReaderHelper
.AddFromGuid "{22E0CB87-9325-4B0F-8ECC-21B271EC81AA}", 1, 0 ' DolbyDLLlib (from 2016 windows 10)
.AddFromGuid "{4486DF98-22A5-4F6B-BD5C-8CADCEC0A6DE}", 1, 0 'LocationApi 1.0 Type Library (from 2016 windows 10)
.AddFromGuid "{012F24C1-35B0-11D0-BF2D-0000E8D0D146}", 1, 0 ' ACTIVEXLib    Microsoft Office Template and Media Control 1.0 Type Library
.AddFromGuid "{00020802-0000-0000-C000-000000000046}", 1, 9 'Microsoft Graph 16.0 Object Library
ElseIf Application.Version = 15 Then
On Error Resume Next
.AddFromGuid GUID_OfficeObject, 2, 8
If Err.Number <> 0 Then
Err.Clear
.AddFromGuid GUID_OfficeObject, 2, 7
End If
If Err.Number <> 0 Then
Err.Clear
.AddFromGuid GUID_OfficeObject, 2, 6
End If
'OutlookSocialProvider
.AddFromGuid "{E301A065-3DF5-4378-A829-57B1EA986631}", 1, 1 'OutlookSocialProvider
If Err.Number <> 0 Then
Err.Clear
.AddFromGuid "{E301A065-3DF5-4378-A829-57B1EA986631}", 1, 0 'OutlookSocialProvider
End If

' Office 2013 (version 15) でMajor,Minor番号が定まっていると考えられるもの
.AddFromGuid GUID_Excel, 1, 8
.AddFromGuid GUID_OUTLOOK, 9, 5
.AddFromGuid GUID_POWERPOINT, 2, 11
.AddFromGuid GUID_MSPub, 2, 2
.AddFromGuid "{3120BA9F-4FC8-4A4F-AE1E-02114F421D0A} ", 1, 0 'Microsoft OneNote 15.0 Extended Object Library 1.0
.AddFromGuid GUID_OLXLib, 1, 1
.AddFromGuid "{113D61B1-C7C0-4157-B694-43594E25DF45}", 1, 1 'eawfctrl 1.0 Type Library
.AddFromGuid GUID_WinWord, 8, 6 'Microsoft Word 15.0 Object Library

ElseIf Application.Version = 14 Then
.AddFromGuid "{E301A065-3DF5-4378-A829-57B1EA986631}", 1, 0 'OutlookSocialProvider 2013 以降はない
.AddFromGuid GUID_OfficeObject, 2, 5
.AddFromGuid GUID_Excel, 1, 7
.AddFromGuid GUID_OUTLOOK, 9, 4
.AddFromGuid GUID_POWERPOINT, 2, 10
.AddFromGuid GUID_MSPub, 2, 1
.AddFromGuid GUID_OLXLib, 1, 1
.AddFromGuid "{1F8E79BA-9268-4889-ADF3-6D2AABB3C32C}", 1, 0 'Microsoft Outlook Social Provider Extensibility
.AddFromGuid "{0EA692EE-BB50-4E3C-AEF0-356D91732725}", 1, 0 'Microsoft OneNote 14.0 Object Library
.AddFromGuid "{113D61B1-C7C0-4157-B694-43594E25DF45}", 1, 0 'eawfctrl 1.0 Type Library
.AddFromGuid GUID_WinWord, 8, 5 'Microsoft Word 14.0 Object Library
End If
End With

Dim refs, ref, n, i
Dim FSO As New FileSystemObject ': Set FSO = CreateObject("Scripting.FileSystemObject")
Dim TS 'As TextStream
Set TS = FSO.CreateTextFile(FSO.BuildPath(CreateObject("Wscript.Shell").ExpandEnvironmentStrings("%USERPROFILE%") & "\Documents", FSO.GetTempName & ".txt"), True, True)
Set refs = Application.VBE.ActiveVBProject.References 'Application.ReferencesではDescriptionが出ない。このため　Refs を Nothing にして、 左のように書き換える

n = PowerPoint.Application.VBE.ActiveVBProject.References.Count
For i = 0 To n - 1
With PowerPoint.Application.VBE.ActiveVBProject.References.Item(i)
Set ref = PowerPoint.Application.VBE.ActiveVBProject.References.Item(i)
If .IsBroken = False Then
TS.WriteLine .Name & "," & .GUID & "," & .Major & "," & .Minor & "," & .Description & "," & .FullPath & "," & .Type
Debug.Print ref.Name, ref.GUID, ref.Major, ref.Minor, ref.Description, ref.FullPath
Else
refs.Remove PowerPoint.Application.VBE.ActiveVBProject.References.Item(i)
End If
End With
Next
TS.Close
Set FSO = Nothing
End Sub
```