I have a workbook that allows the user to send an email of one particular sheet and it works great. In the past, I only had users running MS Office 2007 and 2010. I have code (see below) that would check the version and then reference the the correct Microsoft Outlook 12.0 (or 14.0) Object Library (required, I guess for emailing within Excel) and everything worked. The code you see below was provided by another Forum user. I don't totally understand what's going on, but it works. My problem is that now I have MS Office 2013 users which uses Microsoft Outlook 15.0 Object Library. I need to expand my code to check and recognize Office 2013 (as well as 2007 and 2010) and then reference the appropriate Object Library. Does anyone know what I need to add so that the code will also reference the Microsoft Outlook 15.0 Object Library.
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 Sub
Bookmarks