A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Add appointment to calendar--NOT my default



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old March 5th 09, 02:17 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Add appointment to calendar--NOT my default

CreateItem() will always create the item in the default folder for that type
of item.

You can get a handle to the folder where you want the item created, then get
that folder's Items collection and use the Add() method of the Items
collection to create your item there.

An alternative is to save the item to the default folder and then move it to
the desired target folder.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"GMargen" wrote in message
...
I don't want to add an appointment to my default calendar. I want to add it
to another of my calendars. Let's call it calendar2.
What can I do to tell it to put an appointment in calendar2 instead of my
default calendar?


Private Sub cmdAddAppt_Click()
On Error GoTo Add_Err

'Save record first to be sure required fields are filled.
DoCmd.RunCommand acCmdSaveRecord

'Exit the procedure if appointment has been added to Outlook.
If Me!AddedToOutlook = True Then
MsgBox "This appointment is already added to Microsoft
Outlook"
Exit Sub
'Add a new appointment.
Else
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern

Set objOutlook = CreateObject("Outlook.Application")

Set objAppt = objOutlook.CreateItem(olAppointmentItem)

With objAppt
.Start = Me!ApptStartDate & " " & Me!ApptTime
.Duration = Me!ApptLength
.Subject = Me!Appt

If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
If Not IsNull(Me!ApptLocation) Then .Location =
Me!ApptLocation
If Me!ApptReminder Then
.ReminderMinutesBeforeStart = Me!ReminderMinutes
.ReminderSet = True
End If

Set objRecurPattern = .GetRecurrencePattern

With objRecurPattern
.RecurrenceType = olRecursWeekly
.Interval = 1
'Once per week
' .PatternStartDate = #12/19/2003#
.PatternStartDate = Me!ApptStartDate
'You could get these values
'from new text boxes on the form.
' .PatternEndDate = #7/23/2003#
.PatternEndDate = Me!ApptEndDate
End With

.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
End If

'Release the Outlook object variable.
Set objOutlook = Nothing

'Set the AddedToOutlook flag, save the record, display a
message.
Me!AddedToOutlook = True
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Appointment Added!"

Exit Sub

Add_Err:
MsgBox "Error " & Err.Number & vbCrLf & Err.Description
Exit Sub

End Sub


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting custom appointment form to save to a calendar like the default appt form cmonroe21 via OfficeKB.com Outlook - Using Forms 0 February 26th 09 10:31 PM
How to create an appointment item in a non-default calendar Jennifer Outlook and VBA 4 June 20th 07 04:39 PM
Adding appointment to non default calendar Andy Pope Outlook and VBA 6 June 14th 07 08:18 PM
Changing Calendar Appointment default. Rita Outlook - Calandaring 1 June 7th 06 10:17 PM
How to set Outlook calendar appointment reminder to default 1 hr? Wan G Outlook - Calandaring 1 February 9th 06 04:10 PM


All times are GMT +1. The time now is 05:11 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.