Advertisement

06.26.2007 at 03:03AM PDT, ID: 22657830
[x]
Attachment Details

Activating Excel VBA References programatically

Asked by swordbest in Microsoft Powerpoint Presentation Software, VB Controls, Microsoft Excel Spreadsheet Software

Tags: vba, excel, reference

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-000000000046}, 1, 5, C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE
'// Microsoft Office 11.0 Object Library, {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}, 2, 3, C:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL
'// Microsoft PowerPoint 11.0 Object Library, {91493440-5A91-11CF-8700-00AA0060263B}, 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.References

ID.AddFromGuid "{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}", 1, 5
ID.AddFromGuid "{00020813-0000-0000-C000-000000000046}", 2, 3
ID.AddFromGuid "{91493440-5A91-11CF-8700-00AA0060263B}", 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 SubStart Free Trial
[+][-]06.26.2007 at 03:10AM PDT, ID: 19362208

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.26.2007 at 03:20AM PDT, ID: 19362248

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.26.2007 at 03:30AM PDT, ID: 19362315

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.26.2007 at 03:38AM PDT, ID: 19362355

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.26.2007 at 03:48AM PDT, ID: 19362395

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.26.2007 at 03:55AM PDT, ID: 19362435

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Powerpoint Presentation Software, VB Controls, Microsoft Excel Spreadsheet Software
Tags: vba, excel, reference
Sign Up Now!
Solution Provided By: rorya
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32