Sub CreateRef_Library_ScFso()
' turns on microsoft scripting runtime reference
'// Set a Reference to SCRRUN.DLL = Scripting.FileSystemObject
'// Microsoft scripting Runtime
'// If it already exits Resume & Handle latter!
Dim ID As Object
On Error Resume Next
Set ID = ThisWorkbook.VBProject.References
ID.AddFromGuid "{420B2830-E718-11CF-893D-00A0C9054228}", 1, 0
If Err.Number <> 0 Then
MsgBox ("Err.Number & Err.Description & Err.HelpFile & Err.HelpContext & Microsoft scripting Runtime")
End If
End Sub
Sub ListReferences()
' gives a messeage box showing each reference
Dim oRef As Object
For Each oRef In ActiveWorkbook.VBProject.References
MsgBox oRef.Description
Next oRef
End Sub
Sub ListReferences2()
'list the references and their GUID reference
Dim oRef As Object
For Each oRef In ActiveWorkbook.VBProject.References
'MsgBox oRef.Description
'MsgBox oRef.guid
Debug.Print oRef.Description
Debug.Print oRef.GUID
Debug.Print
Next oRef
End Sub
Sub ListReferences3()
'enable the reference to "Microsoft Visual Basic For Applications Extensibility".
' fills in work sheet with reference name, path, GUID reference
Dim ref As reference
Dim lrow As Long
Range("A1:F1") = Array("Name", "Description", "FullPath", "GUID", "Major", "Minor")
lrow = 2
For Each ref In ThisWorkbook.VBProject.References
Range("A" & lrow) = ref.Name
Range("B" & lrow) = ref.Description
Range("C" & lrow) = ref.FullPath
Range("D" & lrow) = ref.GUID
Range("E" & lrow) = ref.Major
Range("F" & lrow) = ref.Minor
lrow = lrow + 1
Next ref
End Sub
smiler44
Sub RemoveReference()
' this should turn off microsoft scripting runtime
Dim sRefPathName As String, i As Integer
sRefPathName = "c:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB"
With ActiveWorkbook.VBProject
For i = 1 To .References.Count
If LCase(.References(i).FullPath) = LCase(sRefPathName) Then
.References.Remove .References.Item(i)
Exit For
End If
Next i
End With
End Sub