I'm trying to programmatically reference the Excel 16.0 Object Library from a Powerpoint macro. I can't seem to find any information on how to do this.
I think this is the code to add library references within an Excel Workbook:
Sub AddReference()
Dim VBAEditor As VBIDE.VBE
Dim vbProj As VBIDE.VBProject
Dim chkRef As VBIDE.Reference
Dim BoolExists As Boolean
Set VBAEditor = Application.VBE
Set vbProj = ActiveWorkbook.VBProject
'~~> Check if reference is already added
For Each chkRef In vbProj.References
If chkRef.Name = "Microsoft Excel 16.0 Object Library" Then
BoolExists = True
GoTo CleanUp
End If
Next
vbProj.References.AddFromFile "C:\Program Files\Microsoft Office\Root\Office 16\EXCEL.EXE"
CleanUp:
Set vbProj = Nothing
Set VBAEditor = Nothing
End Sub
Adapted from here - Siddharth Rout
However, I get a User-defined type not defined in Powerpoint. I assume it is because the Objects at the start of the Sub are different. Anyone know how to do something similar in Powerpoint?