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 / January 2005

Tip: Looking for answers? Try searching our database.

Calendar entries with duplicate names

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dieter Molle - 31 Jan 2005 12:46 GMT
Hi all,

maybe someone can help me:

i try to edit calendar entries with a VB Script like this:

'---------------------------
Const olFolderCalendar  = 9

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")

Set myOLFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
Set myEntry = myOLFolder.items("Test 1234")
myEntry.Body = "Hello :-)"
myEntry.save
'---------------------------

As you can see, i want to reference the item by its subject. The
script runs fine.

Now my problem is: what if i have two or more calendar items with the
same subject?! This script writes to the first item found.
Can i loop through all items with a special subject?
What i could do was loop throug ALL calendar items and looking for
those where the subject matches, but is there no easier way to do
this?

Thanks in advance for your help,
Greetings,
 Dieter
Ken Slovak - 31 Jan 2005 15:33 GMT
What you can do is set up a filter or restriction on the Items collection of
that folder. A filter can be set up and then you can iterate the Items
collection using FindFirst and FindNext until FindNext returns a null
object. Or with a restriction you get a filtered Items collection that can
just be iterated.

For example:

Const olFolderCalendar  = 9

Set myOlApp = CreateObject("Outlook.Application")
'if run in an Outlook form use Application instead like this:
'Set myNameSpace = Application.GetNameSpace("MAPI")
'no need to create an Outlook Application object

Set myNameSpace = myOlApp.GetNameSpace("MAPI")

Set myOLFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
strRestrict =  "[Subject] = " & """Test 1234"""
Set myItems = myOLFolder.items.Restrict(strRestrict)
For Each myEntry In myItems
   myEntry.Body = "Hello :-)"
   myEntry.save
Next

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

> Hi all,
>
[quoted text clipped - 27 lines]
> Greetings,
>  Dieter
 
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.