Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / November 2006

Tip: Looking for answers? Try searching our database.

Code worked once only. then stopped.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Carol G - 28 Nov 2006 18:52 GMT
I am using Outlook 2000.

I am sure that this code worked once and then stopped working. It is meant
to update data to the outlook contactitem body from a button in an access
database. I check the outlook contact item and nothing is being transferred
into the body.

Any Ideas what I'm doing wrong?

Both strNameList and strNotes have the proper data in them.

Private Sub cmdOutlookExport_Click()

Dim strNameList as String

Dim strNotes as String

Dim fld As Outlook.MAPIFolder

Dim appOutlook As Outlook.Application

Dim nms As Outlook.NameSpace

Dim itms As Outlook.Items

Dim itm As Outlook.ContactItem

Set appOutlook = CreateObject("Outlook.Application")

Set nms = appOutlook.GetNamespace("MAPI")

Set fld = nms.GetDefaultFolder(olFolderContacts) 'Set what kind of folder

Set itms = fld.Items 'Outlook folder item

'Before being called Both strNameList and strNotes have the proper data in
them. This is 'checked in the For Each Loop below.

For Each itm In itms

    If strNameList = itm.FullName Then

      Debug.Print itm.FullName & " is found"

      itm.Body = itm.Body & strNotes

      Debug.Print itm.Body & " is itm.body"

   End If

 Next

 MsgBox "Contact Updated Successfully"

Thanks

Carol
Ken Slovak - [MVP - Outlook] - 28 Nov 2006 19:39 GMT
Try saving the items as you modify them to persist the changes.

Signature

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

>I am using Outlook 2000.
>
[quoted text clipped - 54 lines]
>
> Carol
Carol G - 28 Nov 2006 19:57 GMT
Do you mean?  .Close (olSave)??
I am pretty new to outlook so I'm not sure if this is what you meant.
Thanks
Carol
> Try saving the items as you modify them to persist the changes.
>
[quoted text clipped - 56 lines]
> >
> > Carol
Carol G - 28 Nov 2006 20:02 GMT
Thank you, that worked.
Carol
> Try saving the items as you modify them to persist the changes.
>
[quoted text clipped - 56 lines]
> >
> > Carol
Ken Slovak - [MVP - Outlook] - 28 Nov 2006 20:51 GMT
Actually I was thinking more of itm.Save in the loop after you modify each
contact item.

Signature

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

> Thank you, that worked.
> Carol
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.