[AccessD] Set Reference using VBA

Darryl Collins Darryl.Collins at coles.com.au
Sun Feb 17 19:19:45 CST 2008


hmmmm... I think I have this solved. Just for the archives here is what works.  A brief background.

I have a dll file (MouseWheel.dll) that I need to be recognised and set as a reference.  The file *cannot* be placed in 
 c:\program files\common files\microsoft shared\ and I cannot access the registry due to admin restrictions.  It currently sits on a network drive and can be manually setup from there using TOOLS > References > etc via the VBE.  I want to perform the same thing but using VBA code.

'------------------------------------------------------------------
Function ReferenceFromFile(strFileName As String) As Boolean
    Dim ref As Reference

    On Error GoTo Error_ReferenceFromFile
    Set ref = References.AddFromFile(strFileName)
    ReferenceFromFile = True

Exit_ReferenceFromFile:
    Exit Function

Error_ReferenceFromFile:
    MsgBox Err & ": " & Err.Description
    ReferenceFromFile = False
    Resume Exit_ReferenceFromFile
End Function

'--------------------------------------------
Sub CreateCalendarReference()

Dim sPATH As String

sPATH = "\\dingo\grpdata\IT Project Status Reporting\Icons\MouseWheel.dll"

    If ReferenceFromFile(sPATH) = True Then
        MsgBox "Reference set successfully."
    Else
        MsgBox "Reference not set successfully."
    End If
End Sub
'-------------------------------------------------------------------------



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Darren D
Sent: Monday, 18 February 2008 10:45 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Set Reference using VBA


Hi Darryl

I do have some semi complex code that does what you need - But we will try
simple first
You can wrap a line like the one below in a shell call behind a button or in an
OnLoad event

Somethinglike
~~~~~~~~~~~~~~~~~
Dim strRegPath as string
strRegPath = "regsvr32 c:\program files\common files\microsoft
shared\dao\dao360.dll"
Call Shell (strRegPath, WIN_NORMAL)
~~~~~~~~~~~~~~~~
- That should work - You may have to play about with quotes - not sure
You can then set up variables for passing the relevant DLL etc

Darren
-----------------
T: 1300 301 731

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darryl Collins
Sent: Monday, 18 February 2008 9:45 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Set Reference using VBA


Hey all,

I know this can be done in Excel and am hoping it can be done in access.  Can I
get Access to look for and set a reference to a .dll file using code?

Bascially I want to automate the (from the VBE) Tools > Reference > Set
Reference > (Browse > select > Ok).

Many thanks

Regards
Darryl.

This email and any attachments may contain privileged and confidential
information and are intended for the named addressee only. If you have received
this e-mail in error, please notify the sender and delete this e-mail
immediately. Any confidentiality, privilege or copyright is not waived or lost
because this e-mail has been sent to you in error. It is your responsibility to
check this e-mail and any attachments for viruses.  No warranty is made that
this material is free from computer virus or any other defect or error.  Any
loss/damage incurred by using this material is not the sender's responsibility.
The sender's entire liability will be limited to resupplying the material.

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.20.5 - Release Date: 14/02/2008 12:00 AM
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.20.5 - Release Date: 14/02/2008 12:00 AM
 

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

This email and any attachments may contain privileged and confidential information and are intended for the named addressee only. If you have received this e-mail in error, please notify the sender and delete this e-mail immediately. Any confidentiality, privilege or copyright is not waived or lost because this e-mail has been sent to you in error. It is your responsibility to check this e-mail and any attachments for viruses.  No warranty is made that this material is free from computer virus or any other defect or error.  Any loss/damage incurred by using this material is not the sender's responsibility.  The sender's entire liability will be limited to resupplying the material.




More information about the AccessD mailing list