![]() |
GUID of the Reference
I am trying to write a macro to add a VB Project reference. By using
NewWorkbook.VBProject.References.AddfromGuid("Guid ","Major","Minor") Now how can I find the the GUID, major and minor of the reference that I trying to add? By the way, I am trying to add "Microsoft Visual Basic for Applications Extensibility" and my version is Excel 97. Thanks, |
GUID of the Reference
Try the following:
ThisWorkbook.VBProject.References.AddFromGuid _ GUID:="{0002E157-0000-0000-C000-000000000046}", _ major:=5, minor:=0 -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Anson" wrote in message ... I am trying to write a macro to add a VB Project reference. By using NewWorkbook.VBProject.References.AddfromGuid("Guid ","Major","Mino r") Now how can I find the the GUID, major and minor of the reference that I trying to add? By the way, I am trying to add "Microsoft Visual Basic for Applications Extensibility" and my version is Excel 97. Thanks, |
GUID of the Reference
Add it manually, then query the reference for its GUID using VBA. I think
you can use 0 and 0 for the major and minor and it will use the latest. Sub GetGUID() For Each ref In ThisWorkbook.VBProject.References Debug.Print ref.Name, ref.GUID Next End Sub produced: VBA {000204EF-0000-0000-C000-000000000046} Excel {00020813-0000-0000-C000-000000000046} stdole {00020430-0000-0000-C000-000000000046} Office {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52} MSForms {0D452EE1-E08F-101A-852E-02608C4D0BB4} VBIDE {0002E157-0000-0000-C000-000000000046} where the last one is what you want (but do it in Excel 97 - it might be different) or Sub GetGUID() For Each ref In ThisWorkbook.VBProject.References Debug.Print ref.Name, ref.GUID, ref.Major, ref.Minor Next End Sub VBA {000204EF-0000-0000-C000-000000000046} 4 0 Excel {00020813-0000-0000-C000-000000000046} 1 3 stdole {00020430-0000-0000-C000-000000000046} 2 0 Office {2DF8D04C-5BFA-101B-BDE5-00AA0044DE52} 2 1 MSForms {0D452EE1-E08F-101A-852E-02608C4D0BB4} 2 0 VBIDE {0002E157-0000-0000-C000-000000000046} 5 3 -- Regards, Tom Ogilvy "Anson" wrote in message ... I am trying to write a macro to add a VB Project reference. By using NewWorkbook.VBProject.References.AddfromGuid("Guid ","Major","Minor") Now how can I find the the GUID, major and minor of the reference that I trying to add? By the way, I am trying to add "Microsoft Visual Basic for Applications Extensibility" and my version is Excel 97. Thanks, |
GUID of the Reference
They worked beautifully! Thanks!
"Anson" wrote: I am trying to write a macro to add a VB Project reference. By using NewWorkbook.VBProject.References.AddfromGuid("Guid ","Major","Minor") Now how can I find the the GUID, major and minor of the reference that I trying to add? By the way, I am trying to add "Microsoft Visual Basic for Applications Extensibility" and my version is Excel 97. Thanks, |
All times are GMT +1. The time now is 05:15 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com