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.
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,232
Office Version
  1. 365
Platform
  1. Windows
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.
 

EAnton781

New Member
Joined
Feb 5, 2009
Messages
39
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
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,232
Office Version
  1. 365
Platform
  1. Windows
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.:)
 

EAnton781

New Member
Joined
Feb 5, 2009
Messages
39

ADVERTISEMENT

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
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,232
Office Version
  1. 365
Platform
  1. Windows
How is the code 'bombing' out?

Are you getting any error messages?
 

EAnton781

New Member
Joined
Feb 5, 2009
Messages
39

ADVERTISEMENT

The error is "Data Type is not Supported"

Line is highlighted in my previous post.
 

GTO

MrExcel MVP
Joined
Dec 9, 2008
Messages
6,154
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.
 

EAnton781

New Member
Joined
Feb 5, 2009
Messages
39
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.
 

EAnton781

New Member
Joined
Feb 5, 2009
Messages
39
I'm still a little hazy on how late-binding works. Can either of you recommend a reference online I can study?
 

Watch MrExcel Video

Forum statistics

Threads
1,123,388
Messages
5,601,376
Members
414,447
Latest member
CRAVIN

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
Top