Convert Early Binding VBA to Late Binding VBA : Excel to Outlook Contacts

前端 未结 2 1407
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 01:04

Each employee gets an updated contact list. I\'m creating a macro in Excel that will delete all outlook contacts, then import all the contacts on that sheet into their main

相关标签:
2条回答
  • 2020-12-04 01:41

    To use Late binding, you should declare all your Outlook-specific objects as Object:

    Dim olApp As Object, olNamespace As Object, olFolder As Object, olConItems As Object
    

    Then:

    Set olApp = CreateObject("Outlook.Application")
    

    This will make each computer create the olApp object from the Outlook library that is installed on it. It avoids you to set an explicit reference to Outlook14 in the workbook that you will distribute (remove that reference from the project before distributing the Excel file).

    Hope this helps :)

    0 讨论(0)
  • 2020-12-04 01:49

    All of your Outlook object declarations would first have to become non-Oulook related object declarations.

    Dim olApp As Object 
    Dim olNamespace As Object 
    Dim olFolder As Object 
    Dim olConItems As Object 
    Dim olItem As Object 
    

    You will need a CreateObject function on the Outlook.Application object.

    Set olApp = CreateObject("Outlook.Application")
    

    Everything else should fall into place.

    0 讨论(0)
提交回复
热议问题