A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Late binding sample



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 24th 06, 12:34 AM posted to microsoft.public.outlook,microsoft.public.outlook.interop,microsoft.public.outlook.program_vba
John
external usenet poster
 
Posts: 135
Default Late binding sample

Hi

I have the below code for communicating with outlook. What changes do I need
to do to late bind this code so it does not need references to any
particular version of outlook.

Many Thanks

Regards


Imports System.Reflection
Imports Outlook

Module modContacts
Dim O As Outlook.Application
Dim F As Outlook.MAPIFolder
Dim iCon As Outlook.ContactItem

Sub Contacs2Outlook()

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)
With iCon
.CompanyName = "My Computer"
.Categories = "Clients"
.Save()
End With
End Sub
End Module


Ads
  #2  
Old February 24th 06, 09:47 PM posted to microsoft.public.outlook,microsoft.public.outlook.interop,microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Late binding sample

It would be something like this I believe:

Dim O As Object
Dim F As Object
Dim iCon As Object

Sub Contacs2Outlook()

Dim oContact As Object
O = CreateObject("Outlook.Application")
F = O.Session.GetDefaultFolder(10)
oContact = DirectCast(F.Items.Item(1), Outlook.ContactItem)
oContact.Delete()

iCon = CType(F.Items().Add(2), Outlook.ContactItem)
F.Items().Add(2)
With iCon
.CompanyName = "My Computer"
.Categories = "Clients"
.Save()
End With
End Sub

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"John" wrote:

Hi

I have the below code for communicating with outlook. What changes do I need
to do to late bind this code so it does not need references to any
particular version of outlook.

Many Thanks

Regards


Imports System.Reflection
Imports Outlook

Module modContacts
Dim O As Outlook.Application
Dim F As Outlook.MAPIFolder
Dim iCon As Outlook.ContactItem

Sub Contacs2Outlook()

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)
With iCon
.CompanyName = "My Computer"
.Categories = "Clients"
.Save()
End With
End Sub
End Module



  #3  
Old February 24th 06, 10:09 PM posted to microsoft.public.outlook,microsoft.public.outlook.interop,microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Late binding sample

Although if not logged in already in that context I'd probably want to use
GetNameSpace("MAPI") rather than Session. Some things aren't right if you
use Session that way, it doesn't touch the store.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Eric Legault [MVP - Outlook]" wrote in
message news
It would be something like this I believe:

Dim O As Object
Dim F As Object
Dim iCon As Object

Sub Contacs2Outlook()

Dim oContact As Object
O = CreateObject("Outlook.Application")
F = O.Session.GetDefaultFolder(10)
oContact = DirectCast(F.Items.Item(1), Outlook.ContactItem)
oContact.Delete()

iCon = CType(F.Items().Add(2), Outlook.ContactItem)
F.Items().Add(2)
With iCon
.CompanyName = "My Computer"
.Categories = "Clients"
.Save()
End With
End Sub

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"John" wrote:

Hi

I have the below code for communicating with outlook. What changes do I
need
to do to late bind this code so it does not need references to any
particular version of outlook.

Many Thanks

Regards


Imports System.Reflection
Imports Outlook

Module modContacts
Dim O As Outlook.Application
Dim F As Outlook.MAPIFolder
Dim iCon As Outlook.ContactItem

Sub Contacs2Outlook()

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)
With iCon
.CompanyName = "My Computer"
.Categories = "Clients"
.Save()
End With
End Sub
End Module




  #4  
Old February 24th 06, 10:32 PM posted to microsoft.public.outlook,microsoft.public.outlook.interop,microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Late binding sample

Another potential issue is those pesky anti-virus programs that block calls to CreateObject("Outlook.Application.")

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"Ken Slovak - [MVP - Outlook]" wrote in message ...
Although if not logged in already in that context I'd probably want to use
GetNameSpace("MAPI") rather than Session. Some things aren't right if you
use Session that way, it doesn't touch the store.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Eric Legault [MVP - Outlook]" wrote in
message news
It would be something like this I believe:

Dim O As Object
Dim F As Object
Dim iCon As Object

Sub Contacs2Outlook()

Dim oContact As Object
O = CreateObject("Outlook.Application")
F = O.Session.GetDefaultFolder(10)
oContact = DirectCast(F.Items.Item(1), Outlook.ContactItem)
oContact.Delete()

iCon = CType(F.Items().Add(2), Outlook.ContactItem)
F.Items().Add(2)
With iCon
.CompanyName = "My Computer"
.Categories = "Clients"
.Save()
End With
End Sub

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"John" wrote:

Hi

I have the below code for communicating with outlook. What changes do I
need
to do to late bind this code so it does not need references to any
particular version of outlook.

Many Thanks

Regards


Imports System.Reflection
Imports Outlook

Module modContacts
Dim O As Outlook.Application
Dim F As Outlook.MAPIFolder
Dim iCon As Outlook.ContactItem

Sub Contacs2Outlook()

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)
With iCon
.CompanyName = "My Computer"
.Categories = "Clients"
.Save()
End With
End Sub
End Module




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Late binding sample John Outlook - General Queries 3 February 24th 06 10:32 PM
my appt. reminder is opening a day late. How do I change that bg Outlook - Calandaring 0 February 7th 06 05:51 PM


All times are GMT +1. The time now is 08:57 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.