Results 1 to 2 of 2
Like Tree2Likes
  • 2 Post By Andrew Poulsom

Need to Add Outlook Object Library

This is a discussion on Need to Add Outlook Object Library within the Excel Questions forums, part of the Question Forums category; Hi frnds, I have created macro that extract and save attachment from Outlook in particular folder. And thats works perfectly ...

  1. #1
    Board Regular MUKESHY12390's Avatar
    Join Date
    Sep 2012
    Location
    India
    Posts
    689

    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.
    Code:
     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
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    73,092

    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
    MUKESHY12390 and DocAElstein like this.
    Microsoft MVP - Excel

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
  •  


DMCA.com