By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

Late binding equivalent

P: n/a
Hi

What is the late binding equivalent of the below code?

Many Thanks

Regards
Dim O As Outlook.Application
Dim F As Outlook.MAPIFolder
Dim iCon As Outlook.ContactItem
Dim oContact As Outlook.ContactItem

O = New Outlook.Application

F =
O.Session.GetDefaultFolder(Outlook.OlDefaultFolder s.olFolderContacts)
oContact = DirectCast(F.Items.Item(1), Outlook.ContactItem)
oContact.Delete()

iCon = CType(F.Items().Add(Outlook.OlItemType.olContactIt em),
Outlook.ContactItem)
F.Items().Add(Outlook.OlItemType.olContactItem)

Feb 24 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
CMM
Everything stays the same except:

1) All your "As xxxx" change to "As Object"
2) o = New Outlook.Application changes to o =
CreateObject("Outlook.Application")

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" <Jo**@nospam.infovis.co.uk> wrote in message
news:uV****************@TK2MSFTNGP11.phx.gbl...
Hi

What is the late binding equivalent of the below code?

Many Thanks

Regards
Dim O As Outlook.Application
Dim F As Outlook.MAPIFolder
Dim iCon As Outlook.ContactItem
Dim oContact As Outlook.ContactItem

O = New Outlook.Application

F =
O.Session.GetDefaultFolder(Outlook.OlDefaultFolder s.olFolderContacts)
oContact = DirectCast(F.Items.Item(1), Outlook.ContactItem)
oContact.Delete()

iCon = CType(F.Items().Add(Outlook.OlItemType.olContactIt em),
Outlook.ContactItem)
F.Items().Add(Outlook.OlItemType.olContactItem)

Feb 24 '06 #2

P: n/a
Getting error on Outlook.ContactItem on line below. How do I deal with this?

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

Thanks

Regards

"CMM" <cm*@nospam.com> wrote in message
news:OD**************@TK2MSFTNGP14.phx.gbl...
Everything stays the same except:

1) All your "As xxxx" change to "As Object"
2) o = New Outlook.Application changes to o =
CreateObject("Outlook.Application")

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" <Jo**@nospam.infovis.co.uk> wrote in message
news:uV****************@TK2MSFTNGP11.phx.gbl...
Hi

What is the late binding equivalent of the below code?

Many Thanks

Regards
Dim O As Outlook.Application
Dim F As Outlook.MAPIFolder
Dim iCon As Outlook.ContactItem
Dim oContact As Outlook.ContactItem

O = New Outlook.Application

F =
O.Session.GetDefaultFolder(Outlook.OlDefaultFolder s.olFolderContacts)
oContact = DirectCast(F.Items.Item(1), Outlook.ContactItem)
oContact.Delete()

iCon = CType(F.Items().Add(Outlook.OlItemType.olContactIt em),
Outlook.ContactItem)
F.Items().Add(Outlook.OlItemType.olContactItem)


Feb 24 '06 #3

P: n/a
CMM
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
Feb 24 '06 #4

P: n/a
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" <cm*@nospam.com> wrote in message
news:uR*************@TK2MSFTNGP09.phx.gbl...
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

Feb 25 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.