Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Add References programatically

1 view
Skip to first unread message

pancho

unread,
Jun 4, 2003, 3:51:44 PM6/4/03
to
I need to add the reference to the library "Microsoft
Scripting Runtime" programatically to a new project. Can
you tell me how to doit?
Thanks.
Francisco Mariscal

Bob Phillips

unread,
Jun 4, 2003, 4:03:13 PM6/4/03
to
You can't!

--

HTH

Bob Phillips

"pancho" <fcoma...@hotmail.com> wrote in message
news:02a801c32ad2$b9fc14f0$a601...@phx.gbl...

RB Smissaert

unread,
Jun 4, 2003, 4:06:17 PM6/4/03
to
Install your library manually, then run this macro:


Sub GetLibraryGUID()

Dim c As Byte
Dim myCheck As Long
Dim P As Boolean
Dim Rng As Range
Dim i As Byte

c = ActiveWorkbook.VBProject.References.Count

On Error Resume Next
Dim Message, Title, Default, T As Single
Message = "NUMBER ?" & Chr(13) & "________"
Title = " GET REFERENCES GUID ( 1 TO " & c & " )"
Default = c
T = InputBox(Message, Title, Default, 3500, 3500)

If Not T Mod 1 = 0 Then
Exit Sub
End If

If T < 1 Or T > c Then
Exit Sub
End If

MsgBox "REFERENCE ( " & T & " ) NAME : " & _
ActiveWorkbook.VBProject.References(T).Name & vbCrLf & vbCrLf & _
"MAJOR : " & _
ActiveWorkbook.VBProject.References.Item(T).Major & _
vbCrLf & vbCrLf & "MINOR : " & _
ActiveWorkbook.VBProject.References.Item(T).Minor & _
vbCrLf & vbCrLf & _
"GUID ( " & T & " ) : " & _
ActiveWorkbook.VBProject.References.Item(T).GUID, , _
" REFERENCES GUID : ITEM " & T

myCheck = MsgBox(" PUT INFORMATION IN SHEET ?", _
vbYesNo, " GetLibraryGUID")

If myCheck = vbNo Then
Exit Sub
End If

If ActiveSheet.ProtectContents = True Then
P = True
ActiveSheet.Unprotect
Else
P = False
End If

Range(Cells(ActiveCell.Row, ActiveCell.Column), _
Cells(ActiveCell.Row + 3, ActiveCell.Column + 1)).Select

For Each Rng In Selection.Cells
If Not IsEmpty(Rng) Then
i = i + 1
End If
Next

If i > 0 Then
myCheck = MsgBox(" OVERWRITE DATA IN THIS RANGE ?", _
vbYesNo, " GetLibraryGUID")
If myCheck = vbNo Then
Exit Sub
End If
End If

On Error Resume Next
ActiveCell.Value = "NAME :"
ActiveCell.Offset(1, 0).Value = "MAJOR :"
ActiveCell.Offset(2, 0).Value = "MINOR :"
ActiveCell.Offset(3, 0).Value = "GUID :"
ActiveCell.Offset(0, 1).Value = _
ActiveWorkbook.VBProject.References(T).Name
ActiveCell.Offset(1, 1).Value = _
ActiveWorkbook.VBProject.References.Item(T).Major
ActiveCell.Offset(2, 1).Value = _
ActiveWorkbook.VBProject.References.Item(T).Minor
ActiveCell.Offset(3, 1).Value = _
ActiveWorkbook.VBProject.References.Item(T).GUID

If P = True Then
ActiveSheet.Protect
End If

End Sub


This well tell you the GUID you need to install the library.
Given an example below how to do this.
The last macro shows you how to remove it.


Sub ActivateVBE6EXT_OLB()

Dim R

For Each R In ActiveWorkbook.VBProject.References
If R.GUID = "{0002E157-0000-0000-C000-000000000046}" Then
Exit Sub
End If
Next

On Error GoTo NotFound

ActiveWorkbook.VBProject.References.AddFromGuid _
GUID:="{0002E157-0000-0000-C000-000000000046}", _
Major:=5, Minor:=3

Exit Sub

NotFound:
MsgBox "CAN'T RUN THIS CODE" & vbCrLf & vbCrLf & _
"VBE6EXT.OLB IS NOT ON THIS COMPUTER"

End Sub

Sub RemoveVBE6EXT_OLB()

ActiveWorkbook.VBProject.References.Remove _
ActiveWorkbook.VBProject.References("VBIDE")

End Sub


RBS


"pancho" <fcoma...@hotmail.com> wrote in message
news:02a801c32ad2$b9fc14f0$a601...@phx.gbl...

Bob Phillips

unread,
Jun 4, 2003, 5:38:00 PM6/4/03
to
Well, that's told me <vbg>

Bob

"RB Smissaert" <bartsm...@blueyonder.co.uk> wrote in message
news:eGkh7StK...@TK2MSFTNGP09.phx.gbl...

Myrna Larson

unread,
Jun 5, 2003, 1:20:48 AM6/5/03
to
And me!

Bob Phillips

unread,
Jun 5, 2003, 7:45:31 AM6/5/03
to
One for the files I think Myrna.

Regards

Bob

"Myrna Larson" <myrna...@charter.net> wrote in message
news:apktdvg3mkfribnof...@4ax.com...

0 new messages