Using Word VBA to Create Appointment Items in Outlook 
Author Message
 Using Word VBA to Create Appointment Items in Outlook

I have the following code to add a record to my Outlook calendar, save
it, and then close Outlook.  Unfortunately, it fails since I don't know
how to create a new Outlook appointment item.

   I am using Word 2000 and Outlook 2000.

Here is the Code:

Sub OutlookTest()
Dim appOL As Outlook.Application
Dim nmsNameSpace As Outlook.NameSpace
Dim fldCalendar As Outlook.MAPIFolder
Dim itemCalendar As Outlook.AppointmentItem
Dim ItemsCal As Outlook.Items
Set appOL = CreateObject("outlook.application")
Set nmsNameSpace = appOL.GetNamespace("MAPI")
Set fldCalendar = nmsNameSpace.GetDefaultFolder(olFolderCalendar)
'THE CODE FAILS HERE, THAT IS, IN CREATING THE OUTLOOK APPOINTMENT ITEM!

'Set itemCalendar = outlook.CreateItem (
'Set itemCalendar = Application.CreateItem(1) 'Create appointmentitem
Set itemCalendar = ItemsCal.Add("IPM.AppointmentItem")
With itemCalendar
    .Categories = "Test"
    .start = Now
    .AllDayEvent = True
    .Subject = "This is a test done " & Now
    .Save
End With
End Sub
'appOL.Quit
'Set itemCalendar = Nothing
'Set fldCalendar = Nothing
'Set nmsNameSpace = Nothing
'Set appOL

Thank you!



Tue, 25 Nov 2003 08:51:52 GMT  
 Using Word VBA to Create Appointment Items in Outlook
Your code sets appOL as an Outlook.Application object. Therefore, this is
the object you need to use with the CreateItem method:

    Set itemCalendar = appOL.CreateItem(1)

If you're working with your default Calendar folder, you do not need to use
the Items.Add method.

--

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


Quote:
> I have the following code to add a record to my Outlook calendar, save
> it, and then close Outlook.  Unfortunately, it fails since I don't know
> how to create a new Outlook appointment item.

>    I am using Word 2000 and Outlook 2000.

> Here is the Code:

> Sub OutlookTest()
> Dim appOL As Outlook.Application
> Dim nmsNameSpace As Outlook.NameSpace
> Dim fldCalendar As Outlook.MAPIFolder
> Dim itemCalendar As Outlook.AppointmentItem
> Dim ItemsCal As Outlook.Items
> Set appOL = CreateObject("outlook.application")
> Set nmsNameSpace = appOL.GetNamespace("MAPI")
> Set fldCalendar = nmsNameSpace.GetDefaultFolder(olFolderCalendar)
> 'THE CODE FAILS HERE, THAT IS, IN CREATING THE OUTLOOK APPOINTMENT ITEM!

> 'Set itemCalendar = outlook.CreateItem (
> 'Set itemCalendar = Application.CreateItem(1) 'Create appointmentitem
> Set itemCalendar = ItemsCal.Add("IPM.AppointmentItem")
> With itemCalendar
>     .Categories = "Test"
>     .start = Now
>     .AllDayEvent = True
>     .Subject = "This is a test done " & Now
>     .Save
> End With
> End Sub
> 'appOL.Quit
> 'Set itemCalendar = Nothing
> 'Set fldCalendar = Nothing
> 'Set nmsNameSpace = Nothing
> 'Set appOL

> Thank you!



Tue, 25 Nov 2003 19:32:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using Word VBA to Create Appointment Items in Outlook

2. Using Word VBA to Create Appointment Items in Outlook

3. Using Word VBA to Create Appointment Items in Outlook

4. change that existing outlook appointment item using VB......

5. Create an appointment in Outlook using MAPI

6. create an outlook 2002 appointment from Word 2002

7. Using outlook 2000, can't create item?

8. Creating/Accessing Appointment items from CDO 1.21

9. How to select all appointment items with vba

10. Problems Creating and searching for Appointment Items


 
Powered by phpBB® Forum Software © phpBB Group