-
Notifications
You must be signed in to change notification settings - Fork 45
Code to get the GUI — Globally Unique Identifier — of extensions
Source : http://www.vbaexpress.com/
Author : Ken Puls
Description: This code returns the full path and Globally Unique Identifier (GUID) to each library referenced in the current project (as selected in VBE|Tools|References). These items can be used to install a VBA Reference Library on the fly.
Discussion: This code is useful for determining specific information which can be used to add VBA references using code. The advantage of using the GUID is that it does not change with the version of the program. ie. Microsoft Excel is object model GUID is {00020813-0000-0000-C000-000000000046}, whether you are using Excel 97, 2000, 2002, etc... The advantage of using the full file path is that the library doesn t actually have to be installed/registered with Office... ie you can just copy the reference file to another computer and use it without running a full install. NOTE: In Office 2002 or later, the TRUST ACCESS TO VISUAL BASIC PROJECT box MUST be checked, or the code will not work. (This box is located in Tools|Options|Security|Macro Security|Trusted Publishers)
`
Option Explicit
Sub ListReferencePaths()
Macro purpose: To determine full path and Globally Unique Identifier (GUID)
to each referenced library. Select the reference in the Tools\References
window, then run this code to get the information on the reference s library
On Error Resume Next
Dim i As Long
With ThisWorkbook.Sheets(1)
.Cells.Clear
.Range("A1") = "Reference name"
.Range("B1") = "Full path to reference"
.Range("C1") = "Reference GUID"
End With
For i = 1 To ThisWorkbook.VBProject.References.Count
With ThisWorkbook.VBProject.References(i)
ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Offset(1, 0) = .Name
ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Offset(0, 1) = .FullPath
ThisWorkbook.Sheets(1).Range("A65536").End(xlUp).Offset(0, 2) = .GUID
End With
Next i
On Error GoTo 0
End Sub
`