Results 1 to 4 of 4

Thread: Microsoft Object Library Reference Missing - Outlook to Excel

  1. #1

    Microsoft Object Library Reference Missing - Outlook to Excel

    Hi Community

    I have attached a VBA that works in Excel 2016 but not in Excel/Outlook 2013 that I require.

    The purpose is to pull emails from Outlook 2013 to Excel 2013.

    When I run it, I am getting an error saying:

    Compile Error:
    Can't find project or library

    Sub Get_Emails (olfdStart As Outlook.MAPIFolder, Date1)

    Under References - VBA Project

    Missing: Microsoft Outlook 16.0 Object Library.

    At work we use Excel and Outlook 2013 and I cannot upgrade to say 2016.

    Can any suggest or amend the file attached please as my VBA knowledge is limited.

    I have seen some posts on this topic but do not fully understand it.

    Any help will be most welcome.

    Attached Files Attached Files

  2. #2
    Someone suggested
    changing the code to use late binding, then the version of Outlook being used shouldn't matter and you wouldn't need a reference.

    Not sure how to do this. Can someone help?

    Option Explicit
    Dim n As Long
    Sub Get_data()
        Dim olApp As Outlook.Application
        Dim olNS As Outlook.Namespace
        Dim olFolder As Outlook.MAPIFolder
        Dim Date1, Date2
        Date1 = "01/01/2018"
        Set olApp = Outlook.Application
        Set olNS = olApp.GetNamespace("MAPI")
        Set olFolder = olNS.PickFolder
        n = 2
        Call Get_Emails(olFolder, Date1)
        Set olNS = Nothing
        Set olFolder = Nothing
        Set olApp = Nothing
        Set olNS = Nothing
    End Sub
    Sub Get_Emails(olfdStart As Outlook.MAPIFolder, Date1)
        Dim olFolder As Outlook.MAPIFolder
        Dim olObject As Object
        Dim olMail As Outlook.MailItem
        Dim Recivedt As Date
        Dim RMail As Outlook.Items
        Set RMail = olfdStart.Items.Restrict("[ReceivedTime] >= """ & Date1 & """")
        For Each olObject In RMail 'olfdStart.Items
            If TypeName(olObject) = "MailItem" Then
               ' If olObject.ReceivedTime <= Date1 Then
                    n = n + 1
                    Set olMail = olObject
                    Cells(n, 1) = n
                     'Universal id
                    Cells(n, 2) = olMail.ConversationID
                     'Email id
                    Cells(n, 3) = Get_Sender_Address(olMail) '.SenderEmailAddress
                     'Date and time workings
                    Cells(n, 4) = olMail.ReceivedTime
                    Cells(n, 6) = olMail.Size
                    Cells(n, 7) = olMail.Subject
              '  End If
            End If
        Set olMail = Nothing
        Set olFolder = Nothing
        Set olObject = Nothing
    End Sub

  3. #3
    VBAX Guru mancubus's Avatar
    Dec 2010
    "A beggar of love, second hand hero...King of Dreams"

    1) Posting Code
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  4. #4
    Many thanks

Posting Permissions

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