Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    May 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Late binding (2000/xp)

    This is a follow-up to something I posted yesterday, but I thought I'd just start a new thread anyway.

    I have code to create an Outlook email message in my Access db, but it needs to be used by people who variously have either Office 2000 or XP. I can't just use a reference to 10.0 then, so I'd like to use late binding to solve this. Trouble is, I can't figure out how to create the olMailItem object. The early bound code is like this:

    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
    With MailOutLook
    .To = strTo
    .Display
    End With

    Late bound would go something like:
    Dim appOutlook As Object
    Dim MailOutlook As Object
    Set appOutlook = CreateObject("Outlook.Application")
    etc.

    But what would be the code for the MailItem? I've tried things like
    Set MailOutlook = CreateObject("Outlook.MailItem")
    or Set MailOutlook = appOutlook.CreateItem(olMailItem)

    and some other wild guesses, but I don't know where to look for the correct method here. Does anybody know what this needs? This is the first time I've tried this late binding business, and I'm fairly unsure what I am doing.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Late binding (2000/xp)

    Using development, set a reference to the Outlook library you're using. That way, you can use the Object Browser to look up the Outlook object and its properties, methods etc. Also, when you type
    Dim xxx As Outlook.
    into the Immediate window, the VBE will present a list of possibilities. You'll see that you can use
    Outlook.MailItem.
    So in late binding, you'd use
    Set MailOutlook = CreateObject("Outlook.MailItem")

    You can remove the reference before final testing. Remember that you can't use constants like olMailItem when you're using late binding. You have to look up the numeric value in the Object Browser and use that.

  3. #3
    New Lounger
    Join Date
    May 2002
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Late binding (2000/xp)

    Thanks alot, Hans. Set MailOutlook = CreateObject ("Outlook.MailItem") still wouldn't work, but it turned out it wasn't needed. Your suggestion about using the numeric value of the constant is what I needed. Thanks again.

Posting Permissions

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