MISSING: Microsoft Outlook XX.X Object Library

EAnton781

New Member
Joined
Feb 5, 2009
Messages
39
Hi Everyone,

I have some code in my Excel 2003 document to generate an email message. It references the Microsoft Office 11.0 Object Library.

Problem is, some employees do not have 11.0, they have the 10.0 Object Library. Both 11.0 and 10.0 refer to a file named MSOUTL.OLB

I'm trying to write some code to identify this issue and update the reference selection as needed when the workbook is opened but have had no luck.

My latest attempt is as follows:
Code:
   Dim vbProj As VBProject ' This refers to your VBA project.
   Dim chkRef As Reference ' A reference.
   Dim RefGUID As String
   Dim refPath As String
   ' Refer to the activedocument's VBA project.
   Set vbProj = ActiveWorkbook.VBProject
   ' Check through the selected references in the References dialog box.
   For Each chkRef In vbProj.References
      ' If the reference is broken, send the name to the Immediate Window.
      If chkRef.IsBroken Then
        RefGUID = chkRef.Guid
        refPath = chkRef.FullPath
        vbProj.References.Remove chkRef
        vbProj.References.AddFromGuid RefGUID, 0, 0
      End If
   Next

This code finds a missing reference, clears it, and then attempts to relocate the file based on the registry GUID. The problem is that it even though the file is MSOUT.OLB, it is still looking for a 11.0 version instead of accepting the 10.0 version.

Any thoughts would be much appreciated!

P.S. Yes, i've tried late-binding here, but we are using .UserProperties to embed hidden variables in the email message which we can't get to work without using the object reference.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
How exactly is the UserProperties part not working when you use late-binding?

I would have thought that if everything was set up/referenced correctly you shouldn't have any problems.
 
Upvote 0
Well when I create the email using late binding I'm able to set all of the properties I need except .userproperties

Code:
Set EmbedValues = OutMail.UserProperties.Add(EmbedName, olText)
    EmbedValues.Value = "False"
    EmbedName = "Approved"

With OutMail
    .to = ToAddress
    .subject = SubjectString
    .Attachments.Add ActiveWorkbook.FullName
End with
 
Upvote 0
What's the problem?

Are you getting errors or is the code just not doing what you want?

I notice you have olText in the code you've posted, if you were using late binding that would mean nothing - it's an Outlook VBA constant.

You would either need the library reference or a constant/variable for it.:)
 
Upvote 0
Yes I'm getting errors. I'm still learning this late binding thing. Here's where I'm bombing out.

Code:
    OutApp.Session.Logon
    Dim OLMailItem
    Set OutMail = OutApp.CreateItem(OLMailItem)
    Dim EmbedValues
    Set EmbedValues = OutMail.UserProperties

    EmbedName = "UniqueID" 'embed Unique ID
    [COLOR="Orange"]Set EmbedValues = OutMail.UserProperties.Add(EmbedName, olText)[/COLOR]
    EmbedValues.Value = UniqueID
 
Upvote 0
How is the code 'bombing' out?

Are you getting any error messages?
 
Upvote 0
Change olText to 1. As Norie pointed out, as soon as you change to late-bound, Constants that were from the referenced library are meaningless.
 
Upvote 0
Yeah, I figured it out likely at the same time as you were typing it.

So instead of checking the references, I should be able to get the late binding to work now.

Thanks so much to both of you.
 
Upvote 0
I'm still a little hazy on how late-binding works. Can either of you recommend a reference online I can study?
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,973
Members
448,933
Latest member
Bluedbw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top