Sub Procedure does not work when perform with different window use

T

TS Lim

I develop a VBA sub procudure. This procedure adds a new contact item to the
default outlook folder. It works fine. But when switch to a different window
user and run the sub procedure again, no new contact item is created. Kindly
advise what are the possile cause of this.

Below is part of my procedure for creating new item in the outlook contact
folder.

Dim ol As Outlook.Application
Dim olns As Outlook.NameSpace
Dim olMAPI As Outlook.MAPIFolder
Dim olCI As Outlook.ContactItem
Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set olMAPI = olns.GetDefaultFolder(olFolderContacts)
Set olCI = ol.CreateItem(olContactItem)

olCI.MessageClass = "IPM.Contact"
If Me.LastName <> "" Then olCI.LastName = "ABC"
olCI.Save

Appreciate for your advise.
 
M

Michael Bauer [MVP - Outlook]

Have you copied the same code to the other user's PST file?

BTW: From within VBA you shouldn' start a new root object of the host
application. That is, don't call
Set ol = New Outlook.Application

if you want to use the variable 'ol', use it this way:

Set ol=Application

--
Best regards
Michael Bauer - MVP Outlook

: VBOffice Reporter for Data Analysis & Reporting
: Outlook Categories? Category Manager Is Your Tool
: <http://www.vboffice.net/product.html?pub=6&lang=en>


Am Mon, 18 Aug 2008 01:42:00 -0700 schrieb TS Lim:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top