Sub Procedure does not work when perform with different window use

  • Thread starter Thread starter TS Lim
  • Start date Start date
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.
 
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:
 
Back
Top