Object Library

Hemish

Registered User.
Local time
Today, 13:59
Joined
Jan 20, 2005
Messages
65
Hi,

I have created some code in MS Access 2010 for sending out Emails and formatting Excel Spreadsheets.

Problem is it works fine in 2010, but if a user uses the database in Access 2007 They get an error because the Microsoft Excel and Microsoft Outlook Object library 14 is missing. I know i can assign Object Library 12 and it works.

But is there any code which automatically changes to Object 12 or identifies which version of excel/outlook is installed and assigns the correct Object Library.

Thanks
 
instead of adding references like you did (Tools|references)(early binding) you can add references dynamically(late binding).

Check the access version and choose to add a reference:
Code:
Access.References.AddFromFile "c:\filename.dll"

However you can't use intellisense when you use late binding.

HTH:D
 
For Late-Binding, you create instances of your objects as per the following example:

Code:
Dim adoConn As Object
Set adoConn = CreateObject("ADODB.Connection")

Dim adoCMD As Object
Set adoCMD = CreateObject("ADODB.Command")

Dim adoRS As Object
Set adoRS = CreateObject("ADODB.Recordset")
Also you need to define the constants that will be needed and would have been supplied via having the binding checked in VBA References, Example:

ADO Constants for use with Late Binding ActiveX Data Objects 2.8 Library
http://www.access-programmers.co.uk/forums/showthread.php?t=243088

Once you have that taken care of, I would also suggest running this process on a backup of your database file.

NT Command Script and Documented Steps to Decompile / Compact / Compile an Access DB
http://www.access-programmers.co.uk...to_Decompile_/_Compact_/_Compile_an_Access_DB

In general, it is never wise to downgrade to prior versions of the applications needed to run the custom program. O2007 --> O2010 --> O2013, and not the other way around.
 

Users who are viewing this thread

Back
Top Bottom