Hi everyone!

Is there a way to tick or untick the references from the tools menu not
manually but with a command?
I found in VBA help a command like this:
VBE.ActiveVBProject.References.Count and tried to display in a msgbox the
references of my project but I got no result although I ckecked that when I
opened the references from the tools menu there where 5 references ticked.

Re: VBA references by Heike

Heike
Fri Jul 29 03:06:51 CDT 2005

Hallo Mirka,

try it like this:

Dim xx As Object
On Error Resume Next
Set xx = Application.VBE.ActiveVBProject.References.Item("Shell32")
Application.VBE.ActiveVBProject.References.Remove xx
On Error GoTo 0
Application.VBE.ActiveVBProject.References.AddFromFile
("C:\windows\system32\shell32.dll")

Heike Pertzel / DATA 5 GmbH

"Mirka" <Mirka@discussions.microsoft.com> schrieb im Newsbeitrag
news:1E045E0A-2079-41BF-94C4-D4E6F71E0C27@microsoft.com...
> Hi everyone!
>
> Is there a way to tick or untick the references from the tools menu not
> manually but with a command?
> I found in VBA help a command like this:
> VBE.ActiveVBProject.References.Count and tried to display in a msgbox the
> references of my project but I got no result although I ckecked that when
> I
> opened the references from the tools menu there where 5 references ticked.



Re: VBA references by Jean-Guy

Jean-Guy
Fri Jul 29 22:43:53 CDT 2005

Mirka was telling us:
Mirka nous racontait que :

> Hi everyone!
>
> Is there a way to tick or untick the references from the tools menu
> not manually but with a command?
> I found in VBA help a command like this:
> VBE.ActiveVBProject.References.Count and tried to display in a msgbox
> the references of my project but I got no result although I ckecked
> that when I opened the references from the tools menu there where 5
> references ticked.

Try this to get them listed:

'_______________________________________
Dim i As Long
Dim myRef As String

With VBE.ActiveVBProject.References
For i = 1 To .Count
myRef = myRef & "Ref # " & i & " : " & .Item(i).Name & vbCrLf _
& " Description: " & .Item(i).Description & vbCrLf _
& " Location: " & .Item(i).FullPath & vbCrLf _
& " Registry key: " & .Item(i).GUID & vbCrLf
Next
MsgBox myRef
End With
'_______________________________________

And look up the following methods to programmatically add references:

.AddFromFile
.AddFromGuid

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org