![]() |
Check to see if reference library is enabled
I was given a macro that requires "Microsoft Scripting Runtime" be enabled in
order to work properly. Is there a way I can add a check to see if the user running the macro has it enabled? I want to add a prompt with instructions if they do not but I need to know how to verify first. |
Check to see if reference library is enabled
Private Sub AddRefToScripting()
'______________________________________________ '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯ 'Di Roberto Mensa nick r '______________________________________________ '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯ 'controlla i riferimenti 'se manca il riferimento a Scripting lo aggiunge With Application.VBE If Verifica_Riferimento(.ActiveVBProject, "Scripting") = False Then .ActiveVBProject.References.AddFromGuid _ "{420B2830-E718-11CF-893D-00A0C9054228}", 1, 0 End If End With End Sub Public Function Verifica_Riferimento( _ ByRef oProject As Object, _ ByVal sRef As String) As Boolean '______________________________________________ '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯ 'Di Roberto Mensa nick r '______________________________________________ '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯Â¯ 'Verifica se un riferimento è caricato su 'oProject 'sRef il nome del riferimento nel codice Dim v For Each v In oProject.References If UCase(v.Name) = UCase(sRef) Then Verifica_Riferimento = True Exit Function End If Next End Function regards r Il mio ultimo lavoro ... http://excelvba.altervista.org/blog/...ternative.html "PJ" wrote: I was given a macro that requires "Microsoft Scripting Runtime" be enabled in order to work properly. Is there a way I can add a check to see if the user running the macro has it enabled? I want to add a prompt with instructions if they do not but I need to know how to verify first. |
Check to see if reference library is enabled
I wouldn't do this. Instead have the author of the macro (or you???) change it
so that you use late binding instead of early binding. Some references: http://support.microsoft.com/default...b;EN-US;244167 INFO: Writing Automation Clients for Multiple Office Versions http://support.microsoft.com/default...b;en-us;245115 INFO: Using Early Binding and Late Binding in Automation http://support.microsoft.com/default...b;en-us;247579 INFO: Use DISPID Binding to Automate Office Applications Whenever Possible and Dick Kusleika has a web page at: http://www.dicks-clicks.com/excel/olBinding.htm that explains this with Outlook ========== I'd develop with the references so that I could get the benefit of the intellisense and autocomplete within the VBE, but then change to late binding before sharing with others. PJ wrote: I was given a macro that requires "Microsoft Scripting Runtime" be enabled in order to work properly. Is there a way I can add a check to see if the user running the macro has it enabled? I want to add a prompt with instructions if they do not but I need to know how to verify first. -- Dave Peterson |
Check to see if reference library is enabled
Place a check within the loop...
Dim ref As Variant For Each ref In Application.VBE.ActiveVBProject.References MsgBox ref.Name Next If this post helps click Yes --------------- Jacob Skaria "PJ" wrote: I was given a macro that requires "Microsoft Scripting Runtime" be enabled in order to work properly. Is there a way I can add a check to see if the user running the macro has it enabled? I want to add a prompt with instructions if they do not but I need to know how to verify first. |
All times are GMT +1. The time now is 04:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com