I'm trying to programatically add Excel VBA references to my macro as I am trying to control powerpoint through my excel macro. Here's what I have so far, but my code appears to be adding new references rather than activating existing ones. I tried both AddFromGuid as well as AddFromFile and neither work. Does anyone know how to activate these?
Sub UpdateExcelReferences()
'// Set references to
'// Microsoft Excel 11.0 Object Library, {00020813-0000-0000-C000-0
0000000004
6}, 1, 5, C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE
'// Microsoft Office 11.0 Object Library, {2DF8D04C-5BFA-101B-BDE5-0
0AA0044DE5
2}, 2, 3, C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL
'// Microsoft PowerPoint 11.0 Object Library, {91493440-5A91-11CF-8700-0
0AA0060263
B}, 2, 8, C:\Program Files\Microsoft Office\OFFICE11\msppt.olb
'// whose DLL types are Scripting.FileSystemObject
'// Microsoft scripting Runtime
Dim ID As Object
'On Error Resume Next
Set ID = ThisWorkbook.VBProject.Ref
erences
ID.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-
00AA0044DE
52}", 1, 5
ID.AddFromGuid "{00020813-0000-0000-C000-
0000000000
46}", 2, 3
ID.AddFromGuid "{91493440-5A91-11CF-8700-
00AA006026
3B}", 2, 8
'ID.AddFromFile "C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL]"
'ID.AddFromFile "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE]
"
'ID.AddFromFile "C:\Program Files\Microsoft Office\OFFICE11\msppt.olb]
"
End Sub
Start Free Trial