How to distribute addin with a reference library checked?
Simplest way to handle this problem is late binding, so in that case no
reference to the application extensibility is needed.
As an example:
Sub ListExcelReferences()
'to list all the references in Excel
'-----------------------------------
Dim i As Long
Dim n As Long
Dim lRefCount As Long
Dim VBProj As Object 'late binding
Cells.Clear
Cells(1).Value = "Project name"
Cells(2).Value = "Project file"
Cells(3).Value = "Reference Name"
Cells(4).Value = "Description"
Cells(5).Value = "FullPath"
Cells(6).Value = "GUID"
Cells(7).Value = "Major"
Cells(8).Value = "Minor"
On Error Resume Next 'as an un-saved workbook has no filename yet
For Each VBProj In Application.VBE.VBProjects
n = n + 1
With VBProj
lRefCount = .References.Count
With .References
For i = 1 To lRefCount
n = n + 1
If i = 1 Then
Cells(n, 1).Value = VBProj.Name
Cells(n, 2).Value = VBProj.Filename
If Err.Number = 76 Then 'Path not found
Cells(n, 2).Value = "Project not saved yet"
Err.Clear
End If
End If
Cells(n, 3).Value = .Item(i).Name
Cells(n, 4).Value = .Item(i).Description
Cells(n, 5).Value = .Item(i).FullPath
Cells(n, 6).Value = .Item(i).GUID
Cells(n, 7).Value = .Item(i).Major
Cells(n, 8).Value = .Item(i).Minor
Next i
End With
End With
Next VBProj
Range(Cells(1), Cells(8)).Font.Bold = True
Range(Cells(1), Cells(n, 8)).Columns.AutoFit
End Sub
This will run fine with no reference set.
RBS
"Caroline" wrote in message
...
Hi,
I have created an addin for group people, which need Microsfot Visual
basic
for application extensibility 5.3 be checked. I have done this in my addin
file. But when rest of group people got it and installed, some machines
won't
keep this reference checked. Can I solve this issue in my addin file, so
other people won't need do anything?
|