VBA references

M

Mirka

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.
 
H

Heike Pertzel

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
 
J

Jean-Guy Marcil

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
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top