Solved

Outlook 12 Object Library Compatibility with Office 2003

Posted on 2009-03-31
17
689 Views
Last Modified: 2013-11-25
I have an Access Database I have been working on in Office 2007.  One component is the capability to email a report which required the Outlook 12 Object Libarry to work with the Outlook.Application function in VB.

When I tested the database on Office 2003 which many users still have, the Outlook 12 Object Library fails and causes all sorts of errors.  This is the only place I'm having a problem with reverse compatibility and hope someone has an idea of how to resolve.
0
Comment
Question by:ClearYourSix
  • 7
  • 7
  • 3
17 Comments
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24028959
Hi ClearYourSix,

When working with 2003 change to the Outlook 11 Object Library


Good Luck!

Gary
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24028963
Hello ClearYourSix,

When I automate one Office app from another, I *always* use late binding, which usually papers over these
differences.

If you post your code we Experts can give more specific guidance.  Late binding, in a nutshell:

1) You do not set references to the external library
2) Instead of strongly typing the outside object variables, you declare them as type Object
3) You use CreateObject to instantiate the outside Application, and then use that application variable
as the "root" to tap into the external object model

Regards,

Patrick
0
 

Author Comment

by:ClearYourSix
ID: 24029020
There are over 500 users.  So, the solution I need is something that involves no intervention.  When I look at VB References, I don't have the choice to select Object 11 in addition to Object 12.  See code below.  

When I deleted the reference to Outlook 12, the email capability quit working.  It only works when i have explicitly selected it in the VB Reference Library.  Code is below that originally worked with the Object Library.  
On Error GoTo Err_EMAILIndividual_Click
 
strEmailTo = Forms![Agency Business Plan]![Email_Alias]
strDate = Forms![Agency Business Plan]![Report_Date]
 
DoCmd.OpenReport "Agency Business Plan Report (Agent)", acViewPreview
DoCmd.OutputTo acOutputReport, "Agency Business Plan Report (Agent)", "Snapshot Format", "C:\TEMP\Business Plan Report.snp"
 
 
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
 
   ' Create the Outlook session.
   Set objOutlook = CreateObject("Outlook.Application")
   ' Create the message.
   Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
   With objOutlookMsg
   ' Add the To recipient(s) to the message. Substitute
   ' your names here.
   Set objOutlookRecip = .Recipients.Add(strEmailTo)
   objOutlookRecip.Type = olTo
   ' Set the Subject, Body, and Importance of the message.
   .Subject = "RESULTS: Business Plan Report - " & strDate
   .Body = "Here is your most current business plan report." & vbCrLf & vbCrLf
   .Sensitivity = olPrivate
   ' Add attachments to the message.
   If Not IsMissing(AttachmentPath) Then
   Set objOutlookAttach = .Attachments.Add("C:\TEMP\Business Plan Report.snp")
   End If
   ' Resolve each Recipient's name.
   For Each objOutlookRecip In .Recipients
         If Not objOutlookRecip.Resolve Then
         objOutlookMsg.Display
         End If
         Next
   .Send
   End With
   Set objOutlookMsg = Nothing
   Set objOutlook = Nothing
   Set objOutlookRecip = Nothing
   Set objOutlookAttach = Nothing
   
Kill ("c:\temp\business plan report.snp")
DoCmd.Close acReport, "Agency Business Plan Report (Agent)", acSaveNo
DoCmd.Maximize
Forms("Agency Business Plan").SetFocus
   
 
Exit_EMAILIndividual_Click:
    Exit Sub
Err_EMAILIndividual_Click:
    MsgBox Err.Description
      DoCmd.Close acReport, "Agency Business Plan REport (Agent)", acSaveNo
    DoCmd.Maximize
    Forms("Agency Business Plan").SetFocus
   
   End Sub

Open in new window

0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029044
You can add the 2003 Object to your PC from somebody that has 2003
0
 

Author Comment

by:ClearYourSix
ID: 24029071
tbsgadi:  

How do I get it from them?  The database was originally developed in 2003 and when I switched to 2007, it automatically wiped out the Outlook 11 reference and replaced it with Outlook 12.
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029086
You're just copying the tlb/dll file to your PC
0
 

Author Comment

by:ClearYourSix
ID: 24029131
when I do that and pull it in, where it carry then to office 2003 users or at least stay active?  if so and office 2007 is later installed, will they need to reinstall tool so Outlook 12 is picked up?
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029160
If you have the 2003 library it upgrades to 2007 - not the other way around
0
 

Author Comment

by:ClearYourSix
ID: 24029176
I think I can make that work.  How do I ADD a reference to the library that doesn't show up in the list already?
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029195
You press the browse button & go to the msoutl.olb file
0
 

Author Comment

by:ClearYourSix
ID: 24029216
OK, give me a few hours to track down that file and test it.  Thanks.  Will get back to you tbsagdi.
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029222
Good Luck!
0
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 24029484
Converting to late binding, so that you need *no references* to Outlook...
On Error GoTo Err_EMAILIndividual_Click
 
strEmailTo = Forms![Agency Business Plan]![Email_Alias]
strDate = Forms![Agency Business Plan]![Report_Date]
 
DoCmd.OpenReport "Agency Business Plan Report (Agent)", acViewPreview
DoCmd.OutputTo acOutputReport, "Agency Business Plan Report (Agent)", "Snapshot Format", "C:\TEMP\Business Plan Report.snp"
 
 
Dim objOutlook As Object 'Outlook.Application
Dim objOutlookMsg As Object 'Outlook.MailItem
Dim objOutlookRecip As Object 'Outlook.Recipient
Dim objOutlookAttach As Object 'Outlook.Attachment
 
   ' Create the Outlook session.
   Set objOutlook = CreateObject("Outlook.Application")
   ' Create the message.
   Set objOutlookMsg = objOutlook.CreateItem(0)  'olMailItem
   With objOutlookMsg
   ' Add the To recipient(s) to the message. Substitute
   ' your names here.
   Set objOutlookRecip = .Recipients.Add(strEmailTo)
   objOutlookRecip.Type = 1   'olTo
   ' Set the Subject, Body, and Importance of the message.
   .Subject = "RESULTS: Business Plan Report - " & strDate
   .Body = "Here is your most current business plan report." & vbCrLf & vbCrLf
   .Sensitivity = 2   'olPrivate
   ' Add attachments to the message.
   If Not IsMissing(AttachmentPath) Then
   Set objOutlookAttach = .Attachments.Add("C:\TEMP\Business Plan Report.snp")
   End If
   ' Resolve each Recipient's name.
   For Each objOutlookRecip In .Recipients
         If Not objOutlookRecip.Resolve Then
         objOutlookMsg.Display
         End If
         Next
   .Send
   End With
   Set objOutlookMsg = Nothing
   Set objOutlook = Nothing
   Set objOutlookRecip = Nothing
   Set objOutlookAttach = Nothing
   
Kill ("c:\temp\business plan report.snp")
DoCmd.Close acReport, "Agency Business Plan Report (Agent)", acSaveNo
DoCmd.Maximize
Forms("Agency Business Plan").SetFocus
   
 
Exit_EMAILIndividual_Click:
    Exit Sub
Err_EMAILIndividual_Click:
    MsgBox Err.Description
      DoCmd.Close acReport, "Agency Business Plan REport (Agent)", acSaveNo
    DoCmd.Maximize
    Forms("Agency Business Plan").SetFocus
   
   End Sub

Open in new window

0
 

Author Comment

by:ClearYourSix
ID: 24029508
tbsgadi... got the Outlook 11 file but was unable to get it to override Outlook 12 Object.  Now trying matthew's code....
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 24029528
You need to first untick the outlook l2 object & then browse to the 11
0
 

Author Closing Comment

by:ClearYourSix
ID: 31564829
THANK YOU for editing the code.  I had just started to research what you meant by late-binding.  The code works beautifully.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 24030219
ClearYourSix,

Glad to help :)

Regards,

Patrick
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question