Late binding equivalent

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    #1

    Late binding equivalent

    Hi

    What is the late binding equivalent of the below code?

    Many Thanks

    Regards


    Dim O As Outlook.Applica tion
    Dim F As Outlook.MAPIFol der
    Dim iCon As Outlook.Contact Item
    Dim oContact As Outlook.Contact Item

    O = New Outlook.Applica tion

    F =
    O.Session.GetDe faultFolder(Out look.OlDefaultF olders.olFolder Contacts)
    oContact = DirectCast(F.It ems.Item(1), Outlook.Contact Item)
    oContact.Delete ()

    iCon = CType(F.Items() .Add(Outlook.Ol ItemType.olCont actItem),
    Outlook.Contact Item)
    F.Items().Add(O utlook.OlItemTy pe.olContactIte m)



  • CMM

    #2
    Re: Late binding equivalent

    Everything stays the same except:

    1) All your "As xxxx" change to "As Object"
    2) o = New Outlook.Applica tion changes to o =
    CreateObject("O utlook.Applicat ion")

    And you get rid of the direct casts (since you can't cast to an object time
    you don't know about).

    Oh yeah, and Option Strict Off needs to be at the top of the module, I'm
    pretty sure.


    --
    -C. Moya

    "John" <John@nospam.in fovis.co.uk> wrote in message
    news:uV0K%23JOO GHA.3164@TK2MSF TNGP11.phx.gbl. ..[color=blue]
    > Hi
    >
    > What is the late binding equivalent of the below code?
    >
    > Many Thanks
    >
    > Regards
    >
    >
    > Dim O As Outlook.Applica tion
    > Dim F As Outlook.MAPIFol der
    > Dim iCon As Outlook.Contact Item
    > Dim oContact As Outlook.Contact Item
    >
    > O = New Outlook.Applica tion
    >
    > F =
    > O.Session.GetDe faultFolder(Out look.OlDefaultF olders.olFolder Contacts)
    > oContact = DirectCast(F.It ems.Item(1), Outlook.Contact Item)
    > oContact.Delete ()
    >
    > iCon = CType(F.Items() .Add(Outlook.Ol ItemType.olCont actItem),
    > Outlook.Contact Item)
    > F.Items().Add(O utlook.OlItemTy pe.olContactIte m)
    >
    >
    >[/color]


    Comment

    • John

      #3
      Re: Late binding equivalent

      Getting error on Outlook.Contact Item on line below. How do I deal with this?

      iCon = CType(F.Items() .Add(2), Outlook.Contact Item)

      Thanks

      Regards

      "CMM" <cmm@nospam.com > wrote in message
      news:ODXHS3OOGH A.1216@TK2MSFTN GP14.phx.gbl...[color=blue]
      > Everything stays the same except:
      >
      > 1) All your "As xxxx" change to "As Object"
      > 2) o = New Outlook.Applica tion changes to o =
      > CreateObject("O utlook.Applicat ion")
      >
      > And you get rid of the direct casts (since you can't cast to an object
      > time you don't know about).
      >
      > Oh yeah, and Option Strict Off needs to be at the top of the module, I'm
      > pretty sure.
      >
      >
      > --
      > -C. Moya
      > www.cmoya.com
      > "John" <John@nospam.in fovis.co.uk> wrote in message
      > news:uV0K%23JOO GHA.3164@TK2MSF TNGP11.phx.gbl. ..[color=green]
      >> Hi
      >>
      >> What is the late binding equivalent of the below code?
      >>
      >> Many Thanks
      >>
      >> Regards
      >>
      >>
      >> Dim O As Outlook.Applica tion
      >> Dim F As Outlook.MAPIFol der
      >> Dim iCon As Outlook.Contact Item
      >> Dim oContact As Outlook.Contact Item
      >>
      >> O = New Outlook.Applica tion
      >>
      >> F =
      >> O.Session.GetDe faultFolder(Out look.OlDefaultF olders.olFolder Contacts)
      >> oContact = DirectCast(F.It ems.Item(1), Outlook.Contact Item)
      >> oContact.Delete ()
      >>
      >> iCon = CType(F.Items() .Add(Outlook.Ol ItemType.olCont actItem),
      >> Outlook.Contact Item)
      >> F.Items().Add(O utlook.OlItemTy pe.olContactIte m)
      >>
      >>
      >>[/color]
      >
      >[/color]


      Comment

      • CMM

        #4
        Re: Late binding equivalent

        Sheesh. If the starting point I gave couldn't get you started, you really
        shouldn't be programming. I mean, seriously...it seems that some really
        really BASIC concepts are eluding you. You're basically looking for someone
        to do it *for you*

        Why are using CType? Do you know what it does? Stop trying to "cast." Same
        goes for the constant "olContactItem. " Find out what integer this represents
        (um, research... use your wits) and use that in the place of the constant.

        --
        -C. Moya



        Comment

        • John

          #5
          Re: Late binding equivalent

          Actually I have already done it after your first post but before the second
          post and just wanted to double check the small point. As you can see I had
          already determined and used the constant. Thanks for the original post that
          helped me to complete this successfully.

          Regards

          "CMM" <cmm@nospam.com > wrote in message
          news:uRGAlhPOGH A.536@TK2MSFTNG P09.phx.gbl...[color=blue]
          > Sheesh. If the starting point I gave couldn't get you started, you really
          > shouldn't be programming. I mean, seriously...it seems that some really
          > really BASIC concepts are eluding you. You're basically looking for
          > someone to do it *for you*
          >
          > Why are using CType? Do you know what it does? Stop trying to "cast." Same
          > goes for the constant "olContactItem. " Find out what integer this
          > represents (um, research... use your wits) and use that in the place of
          > the constant.
          >
          > --
          > -C. Moya
          > www.cmoya.com
          >[/color]


          Comment

          Working...