Microsoft Object Library Version

dsk96m

New member
Local time
Today, 10:04
Joined
Mar 23, 2012
Messages
7
So i have an access database that uses outlook/excel/etc. I developed it in access 2007. So I selected the 12.0 version of the object libraries (ie Microsoft Excel 12.0 Object Library). Since then some have upgraded to Office 2010. So there is a mix of people using access that have either office 2010 or 2007. I am using 2010, so it must automatically select the 14.0 version instead, but when someone who still uses 2007 uses the db, they get errors with missing references, etc bc it doesnt see the 14.0. Shouldnt it automatically select the 12.0 version for them.

How do I get around this object reference issue? I know I can check which version of office they are running, can I then add the appropriate reference in code based on that check?

Any ideas, please help. Thank you.
 
You need to use what is known as late binding and remove the references in the library (which is early binding)

This article will help to explain the differences and what you need to do to convert from one to the other - it is not difficult

http://support.microsoft.com/kb/245115

For me, the main advantage of early binding is that as a developer you can use intellisense - and once the package is completed, convert to late binding.

There are potential performance issues in using late binding however in my experience they are negligable
 
Thank you, will give that a try. That is how I had it, but I had the reference selected, so I unselected them. Will see what happens.
 
So i have this:
Dim objoutlook As Object
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment

Dim Addr As String

'create Outlook sesion
Set objoutlook = CreateObject("Outlook.Application")

It is failing on the bold lines, what do i change that to?
 
As you have removed the Reference, Outlook is no longer something that the compiler would understand.. So you have to create the object as you have created for Outlook..
Code:
Dim objoutlook As Object
Dim objOutlookRecip [B]As Object [/B]
Dim objOutlookAttach [B]As Object [/B]
Dim Addr As String

'create Outlook sesion
Set objoutlook = CreateObject("Outlook.Application")
Set objOutlookRecip = [B]CreateObject("Outlook.Recipient")[/B]
Set objOutlookAttach = [B]CreateObject("Outlook.Attachment")[/B]
 
Thanks Paul - All detailed in the link!
 
That didnt work. Here is my code.

Code:
    Dim cnn As Database
    Dim Dist_list As Recordset
    Dim qdQry As QueryDef
    Dim Email_Msg As String
    Dim Addr As String
    Dim objoutlook As Object
    Dim objOutlookRecip As Object
    Dim objOutlookAttach As Object
    
    Set objoutlook = CreateObject("Outlook.Application")
    Set objOutlookRecip = CreateObject("Outlook.Recipient")
    Set objOutlookAttach = CreateObject("Outlook.Attachment")
    objoutlook.Session.Logon
    
    Set objoutlookmsg = objoutlook.CreateItem(olMailItem)
    
   
    'get list of email addresses
    Set cnn = CurrentDb()
    Set qdQry = cnn.QueryDefs("qry_satt_report_Dist")
    Set Dist_list = qdQry.OpenRecordset
    Dist_list.MoveFirst
    'add the TO recipients to the message
    
    
    Do While Not Dist_list.EOF
        Addr = Dist_list("email_address")
        Set objOutlookRecip = objoutlookmsg.Recipients.Add(Addr)
        objOutlookRecip.Type = olBCC
        Dist_list.MoveNext
    Loop
 
What do you mean by "it did not work", error message? app crash? not sending out emails?

You have not set up olMailItem in the code..
 
I did, everything up to adding the recipients works, but setting the recipients is failing
 
It sends the email, but none of my recipients get it. i get the system admin email response

This message could not be sent. Try sending the message again later, or contact your network administrator. Error is [0x80070057-00000000-00000000].
 
with late binding, things like

objOutlookRecip.Type = olBCC

won't work unless you set these up as constants first:

Const olBCC=3

or just use the number in the code

objOutlookRecip.Type = 3
 

Users who are viewing this thread

Back
Top Bottom