+ Reply to Thread
Results 1 to 9 of 9

How can I reference Microsoft Outlook 15.0 Object Library?

Hybrid View

  1. #1
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    How can I reference Microsoft Outlook 15.0 Object Library?

    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

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How can I reference Microsoft Outlook 15.0 Object Library?

    Why not just use late binding and no reference?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor rkjudy's Avatar
    Join Date
    03-31-2009
    Location
    Longview, TX
    MS-Off Ver
    MS Office 2010
    Posts
    239

    Re: How can I reference Microsoft Outlook 15.0 Object Library?

    I would love to make this as simple as possible. I'm not familiar with late binding, but if this will make it where anyone using any version will be able to email within Excel, I would appreciate help with an example. Thanks.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How can I reference Microsoft Outlook 15.0 Object Library?

    Declare all of the Outlook variables as Object, and use CreateObject to instance the Outlook application. You will need to declare all enumerations that would otherwise come from the library.

    I can't show you an example for Outlook (never done any Outlook automation), but here's an example of code that can be switched from early-bound for development (which gives you Intellisense) to late-bound for deployment:

    #Const EarlyBound = False
    
    Function WriteUTF8(sText As String, sFile As String) As Boolean
      ' Returns True if sText saved successfully as UTF-8 in sFile
    
      On Error GoTo Oops
    
      #If EarlyBound Then
        ' Requires a reference to Microsoft ActiveX Data Objects
        With New ADODB.Stream
      #Else
        ' No reference required
        Const adTypeText As Long = 2
        Const adSaveCreateOverWrite As Long = 2
        With CreateObject("ADODB.Stream")
      #End If
          .Type = adTypeText
          .Charset = "utf-8"
          .Open
          .WriteText sText
          .SaveToFile FileName:=sFile, Options:=adSaveCreateOverWrite
          WriteUTF8 = True
        End With
        Exit Function
    
    Oops:
      MsgBox Err.Description
    End Function

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: How can I reference Microsoft Outlook 15.0 Object Library?

    I have an example of early vs late binding for Outlook here: http://excelmatters.com/?p=69
    Everyone who confuses correlation and causation ends up dead.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: How can I reference Microsoft Outlook 15.0 Object Library?

    Rory, your site looks GREAT!

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,064

    Re: How can I reference Microsoft Outlook 15.0 Object Library?

    Thanks. Still needs a lot of work!

  8. #8
    Registered User
    Join Date
    06-04-2012
    Location
    pune
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: How can I reference Microsoft Outlook 15.0 Object Library?

    Private Sub Workbook_Open() 'Reference - Microsoft Outlook 15.0 Object Library
    Dim wbRef As Variant, wbRefFound As Boolean
    wbRefFound = False

    For Each wbRef In ThisWorkbook.VBProject.References
    Debug.Print wbRef.Description
    If wbRef.Description = "Microsoft Outlook 12.0 Object Library" Or _
    wbRef.Description = "Microsoft Outlook 14.0 Object Library" Or _
    wbRef.Description = "Microsoft Outlook 15.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 or 15.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

    Hope is it work for you. Because it is working on my system. I am using 2013

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,865

    Re: How can I reference Microsoft Outlook 15.0 Object Library?

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [CODE] [/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro to fix missing:microsoft outlook 14.0 object library
    By sujithy007 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-13-2021, 09:59 AM
  2. Microsoft HTML Object Library
    By akotronis in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-29-2013, 01:07 AM
  3. Excel won't allow me to add reference to Microsoft outlook object library
    By Skyla157 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-19-2013, 07:38 PM
  4. VBA References - Microsoft Outlook 14.0 Object Library - load with macro
    By bltn in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-18-2013, 11:28 AM
  5. [SOLVED] Re: Outlook 11 > Outlook 10 Object Library Compatibility Issues
    By DW in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-18-2006, 11:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1