PC Review


Reply
Thread Tools Rate Thread

Check to see if reference library is enabled

 
 
PJ
Guest
Posts: n/a
 
      5th Jun 2009
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.
 
Reply With Quote
 
 
 
 
r
Guest
Posts: n/a
 
      5th Jun 2009
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.

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      5th Jun 2009
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
 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      6th Jun 2009
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check if RDP is Enabled? Polaris Windows XP Security 6 1st Mar 2005 01:37 AM
PC Check says some HD is not DMA enabled. How to enable? alt ATI Video Cards 3 19th Feb 2005 09:41 AM
Reference Library - Missing Library in a lower version. =?Utf-8?B?bHV2Z3JlZW4=?= Microsoft Excel Programming 1 7th Oct 2004 02:08 AM
how to check whether asp.net is installed/enabled with c#? zimmy Microsoft ASP .NET 5 9th Jul 2004 08:37 PM
Error when Solver Reference Enabled BU_Paul Microsoft Excel Programming 4 29th Mar 2004 06:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:42 AM.