Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logical reference type check in VBA 2

Status
Not open for further replies.

mguidry5

Technical User
Jan 11, 2005
91
US
Howdy,

I'm trying to use the CDO sendmail method that I found in a FAQ here, but I have some computers that are sure to not have the CDOsys reference enabled on their machines. If I use late binding to set this reference, I get errors when and if the reference is already set. I use this to set the reference before running the CDO email code in a form module:
Code:
References.AddFromFile "C:\WINDOWS\System32\cdosys.dll"

Is there a way to logically check whether this reference is already set on the machine running the code, and only set it if it is not?
 


Dim ref As Access.Reference

For Each ref In Application.References
Debug.Print ref.Name
Next
 
Code:
Dim ref As Reference
dim isref as Boolean
isref = false
' Enumerate through References collection.
For Each ref In References
     If ref.fullpath = "C:\WINDOWS\System32\cdosys.dll" Then
        isref= true
        exit for
     else      

     EndIf
Next ref
if isref = false then
  References.AddFromFile "C:\WINDOWS\System32\cdosys.dll"
end if
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top