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.
 
I cannot, but other than the help file, I would search MSDN.

Norie may well show a better way, but in general, I find it easiest to write the code early bound (intellisense just makes things so much easier), then when all happy and warm and fuzzy that no smoke pours out of the PC when I run the code, I go back and 'fix' Constants and such.

Once you've done it a couple of times, you'll start catching where you need to do this as you write. While in early bound, right-click on the constants and get quick info.

I would also suggest looking at Enum. This way you can name constants same/similar, which keeps the code intuitive (ie - your eyes don't bleed when reading/editing/updating several months later) and still allows late bound.

Hope that helps,

Mark
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
EAnton

I've got to agree with Mark - develop using early binding and once you have everything working convert to late binding.

One of the main advantages of doing thing's this way is that, as Mark mentions, you have access to Intellisense and you can also use the Object Browser.

I actually used the Object Browser in Outlook VBA to find out more information about UserProperties.

It's not something I've ever used, but then I've never really automated Outlook/email much.:)

You could replace olText with 1 or you could add a declaration like this and then use that in your code.
Code:
Const olText = 1
 
Upvote 0

Forum statistics

Threads
1,214,405
Messages
6,119,323
Members
448,887
Latest member
AirOliver

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