Bonjour,
Dans son message, < James > écrivait :
In this message, < James > wrote:
|| Are you advocating a manual creation of the reference? If not, can you
Yes.
|| explain the steps I would need to take to create the reference in the
|| project via the VBE window programatically?
For most projects, you do not need to do this programmatically. But since
you seem to be dead set on doing it that way, here is some code that may
bring you some joy:
'_______________________________________
Sub AddNewRef()
'Adding Excel
'
'To get the GUID number,
'and the Long for Major/Minor,
'Add the reference manually,
'Run GetNameofAllRef to get the name
'and then run the RemoveRef Sub
ActiveDocument.VBProject.References _
.AddFromGuid "{00020813-0000-0000-C000-000000000046}", 1, 4
End Sub
'_______________________________________
'_______________________________________
Sub RemoveRef()
Dim i As Long
With ActiveDocument.VBProject.References
For i = 1 To .Count
If .Item(i).Name = "Excel" Then
MsgBox .Item(i).Description
MsgBox .Item(i).GUID
MsgBox .Item(i).Major
MsgBox .Item(i).Minor
.Item(i).Collection.Remove .Item(i)
End If
Next i
End With
End Sub
'_______________________________________
'_______________________________________
Sub GetNameofAllRef()
Dim i As Long
With ActiveDocument.VBProject.References
For i = 1 To .Count
MsgBox .Item(i).Name
Next i
End With
End Sub
'_______________________________________
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
[email protected]
Word MVP site:
http://www.word.mvps.org