I have a workbook that will email a particular sheet. I am a novice so I just looked for examples to make this work. The problem I'm having is setting the reference to activate the correct Microsoft Outlook Object Library at WorkBook Open. I have users running 2010 and 2013. The code for actually sending the sheet is okay i think, but the MS Outlook Object Library reference shows missing so they can't use the function. I, personally, am running 2013, and MS Outlook Object Library 15.0 is checked in my references. I'm really not sure why it works on my machine and not others. I use a WorkBook Open module to load the reference. I've been told I should use Late Binding, but I simply don't know how to do that. I just hope I'm explaining my problem properly. The WorkBook Open code is below. Any suggestions?
Private Sub Workbook_Open()
Application.ScreenUpdating = False
Application.DisplayFormulaBar = False
Dim wbRef As Variant, wbRefFound As Boolean
wbRefFound = False
For Each wbRef In ThisWorkbook.VBProject.References
If wbRef.Description = "Microsoft Outlook 12.0 Object Library" Or _
wbRef.Description = "Microsoft Outlook 14.0 Object Library" Then
wbRefFound = True
Exit For
End If
Next
If wbRefFound = False Then
Dim Reference As Object
Dim OLB As String
Dim Vmajor, Vminor
'Load Microsoft Outlook 12.0 or 14.0 Object Library
OLB14 = "{00062FFF-0000-0000-C000-000000000046}"
Vmajor14 = 9
Vminor14 = 4
OLB12 = "{00062FFF-0000-0000-C000-000000000046}"
Vmajor12 = 9
Vminor12 = 3
If Application.Version = 12 Then
ThisWorkbook.VBProject.References.AddFromGuid OLB12, Vmajor12, Vminor12
Else
ThisWorkbook.VBProject.References.AddFromGuid OLB14, Vmajor14, Vminor14
End If
End If
End If
End Sub
Bookmarks