I am trying to use code to add an item to a Calendar folder when I close a
Contact item. I found an example which adds a Contact and I thought I would
try that and modify it accordingly. But I get an error running the code in
its original form saying that the object doesn't support this property or
method. The only other difference is that I run this code in an Item_Close()
Function while the example ties it to a Button_Click.
I have highlighted the line where the error occurs.
Dim nmsp 'namespace object
Dim objContactsFolder 'default contacts folder in the logged-on profile
Dim objNewContact 'new contact item object
Dim objUserProperties 'custom fields collection in the current item
Const olFolderContacts = 10 'standard Outlook constant - has to be defined
Set nmsp = Item.Application.GetNameSpace("MAPI")
Set objContactsFolder=nmsp.GetDefaultFolder(olFolderContacts)
Set objNewContact = objContactsFolder.Add ' ERROR OCCURS HERE
Set objUserProperties = Item.UserProperties
objNewContact.Fullname = objUserProperties.Find("txtOrgName").Value
' objNewContact.Email1Address =
objUserProperties.Find("EmailAddress").Value
objNewContact.Save 'release all object variables
Set objNewContact = Nothing
Set objUserProperties = Nothing
Set objContactsFolder = Nothing
Set nmsp = Nothing
Thanks,
John
--
Sue Mosher, Outlook MVP
Author of
Teach Yourself Microsoft Outlook 2000 Programming in 24 Hours
Microsoft Outlook 2000 E-mail and Fax Guide
Outlook and Exchange solutions at http://www.slipstick.com
"John van Nieuwkerk" <joh...@corangamite.vic.gov.au> wrote in message
news:OiITHtNrAHA.2204@tkmsftngp02...
I've ordered your Teach ourself book. Hopefully I'll be able to answer a lot
of these questions once I've worked though it.
John
"Sue Mosher" <sue...@slipstick.com> wrote in message
news:OuWOqKVrAHA.1892@tkmsftngp04...
Try the following: Set objNewContact = objContactsFolder.Items.Add
Hollis D. Paul [MVP - Outlook]
Hol...@outlookbythesound.com
h...@compuserve.com
Using Virtual Access 4.52 build 277 (32-bit), Windows 2000 build 2195
Mukilteo, WA USA
John
"Hollis D. Paul" <Hol...@outlookbythesound.com> wrote in message
news:VA.00000a8e.6ba7e73b@obts-outlookdev...