Results 1 to 2 of 2

Thread: Need to Add Outlook Object Library
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular MUKESHY12390's Avatar
    Join Date
    Sep 2012
    Post Thanks / Like
    1 Post(s)
    0 Thread(s)

    Default Need to Add Outlook Object Library

    Hi frnds,

    I have created macro that extract and save attachment from Outlook in particular folder.
    And thats works perfectly but whenever I use same macro in MS office 2010 through missing reference error , then I need to add outlook 14.0 reference everytime used in 2010.Currently I am using 2007

    Is there any way to overcame this problem.
     Dim myOlapp As Outlook.Application
        Dim myNameSpace As Outlook.Namespace
        Dim myFolder As Outlook.MAPIFolder
        Dim myItem As Outlook.MailItem
        Dim myAttachment As Outlook.Attachment
        Dim i As Long
        Dim dpath As String
        dpath = ThisWorkbook.Sheets("Macro").Range("C9")
        LP = ThisWorkbook.Sheets("Macro").Range("B9")
        Set myOlapp = CreateObject("Outlook.Application")
        Set myNameSpace = myOlapp.GetNamespace("MAPI")
        Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
        Set myFolder = myFolder.Folders(LP) ''' getting error here
    Thats not whole macro, because that would be little confusing.

    Any small suggetion will be appreciated

    Thanks in Advance.
    MS Office 2010/ Windows 7/8.1
    Concern yourself not with what you tried and failed in, but with what it is still possible for you to do..

  2. #2
    MrExcel MVP
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Post Thanks / Like
    0 Post(s)
    1 Thread(s)

    Default Re: Need to Add Outlook Object Library

    Use late binding rather than early binding. Here is an article that may help you:

    VBA references and early binding vs late binding | Excel Matters
    Microsoft MVP - Excel

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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