Use VBA to automatically add VBProject References to PowerPoint Library, dependent on the Office Version PC is running
<p><strong>Introduction</strong>: I have a VBA application ~ 5000 lines that manipulates data in Excel, builds automatic charts and then exports the charts from each sheet to different PowerPoint Slides. This has been working fine for the past 5 months on many computers that are running this Code.</p>

<p><strong>Problem</strong>: Some of the PCs in my organization have been upgraded from Office 2010 to Office 2013 and Office 2016. In my code I am using Early Binding on my PowerPoint handling, this is resulting in Errors since the References of the VB Project have changed from "<strong><em>Microsoft PowerPoint 14.0 Object Library</em></strong>" to "<strong><em>Microsoft PowerPoint 15.0 Object Library</em></strong>".</p>

<p><strong>Target</strong>: how do I change the References automatically by code according to the PowerPoint version of the PC running my code ?</p>

<p><strong>Status</strong>: My current code is able to loop through all enabled VBProject References, check if any of them is "Missing", and remove them to avoid the error message. I am also able to add PowerPoint 14.0 library by code.</p>

<p><strong>My Question</strong>: how do I add the PowerPoint library according to the PowerPoint running on the PC of current user running this code, when PowerPoint is not running ? How can I read the PowerPoint version installed on a PC when it's not running ? </p>

<p>Also, is the folder location of "Microsoft PowerPoint 15.0 Object Library" and "Microsoft PowerPoint 16.0 Object Library" and other versions change if you run the PC on different Windows Versions ? Like <strong>Win7 32-bit</strong> is different than <strong>Win10 32-bit</strong> ? and different than <strong>Win10 64-but</strong> ?</p>

<p><strong>"Bonus" Question</strong>: I couldn't find anywhere online a chart (or a list) that stores all the data for folder locations of the <strong>"MSPPT.OLB"</strong> file, for different operating systems, and different Office versions.</p>

<hr>

<h2>My Current Code</h2>

<pre><code>Option Explicit

Sub RemoveMissingReferences_AddReference()

'    display Windows Version installed on this PC
'    Win7.      (=6.1, 64bit)
'    Win8       (=6.2, 64bit)
'    Win8.1     (=6.3*)
'    Win10      (=10.0*)
'
MsgBox "Windows Version is: " &amp; getVersion
MsgBox "Excel Version is: " &amp; Application.Version

Dim theRef As Variant, i As Long
Dim ProjRef() As String

ReDim ProjRef(1 To ThisWorkbook.VBProject.References.count)
'Remove any missing references
For i = ThisWorkbook.VBProject.References.count To 1 Step -1
    Set theRef = ThisWorkbook.VBProject.References.Item(i)
    ProjRef(i) = theRef.FullPath ' read path to string array , will use it later

    ' if reference is "Missing" &gt;&gt; remove it to avoid error message
    If theRef.isbroken = True Then
        ThisWorkbook.VBProject.References.Remove theRef
    End If
Next i

' add a Reference to PowerPoint , according to version running on the PC
Dim NewRef_FullPath As String
NewRef_FullPath = "C:\Program Files (x86)\Microsoft Office\Office14\MSPPT.OLB" ' Add PowerPoint 2010 Windows 7-32Bit

' loop through all existing references and check if new requested reference already checked
For i = 1 To UBound(ProjRef)
    If InStr(1, ProjRef(i), NewRef_FullPath) &gt; 0 Then  ' reference already installed on PC &gt;&gt; pevious code runs
        MsgBox "New Ref already installed"
        Exit Sub
    End If
Next i

On Error GoTo CanNotAddPowerPoint
Application.VBE.ActiveVBProject.References.AddFromFile NewRef_FullPath  'try to add a reference to PowerPoint
MsgBox "New Ref successfully installed"

Exit Sub
CanNotAddPowerPoint:
MsgBox "Can not reference PowerPoint"

End Sub
</code></pre>