PC Review


Reply
Thread Tools Rate Thread

Add appointment to calendar--NOT my default!

 
 
Clddleopard
Guest
Posts: n/a
 
      21st Feb 2009
So, I'm a cut and paster when it comes to VBA, and I was able to modify this
to use my tables to add to my default calendar. However, I don't want to add
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!ApptDate & " " & 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
'You can hard-wire in these dates or get the
'information from text boxes, as used here.
'.PatternStartDate = #12/1/2003#
.PatternStartDate = Me!ApptStartDate
'.PatternEndDate = #12/30/2003#
.PatternEndDate = Me!ApptEndDate
End With
.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
End If
'Release the object variables.
Set objOutlook = Nothing
.....Set objRecurPattern = 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

 
Reply With Quote
 
 
 
 
David H
Guest
Posts: n/a
 
      21st Feb 2009
Since I'm such a great guy, I'll be nice and point you in the right
direction...

http://www.outlookcode.com/d/code/getfolder.htm

(You'll still need to adapt the code.)

....and then tell you that you should post this is in the Outlook newsgroup
as this one focuses on the features and functionality of Access and does not
cover automating Outlook from Access per se.

http://www.microsoft.com/office/comm...&lang=en&cr=US

"Clddleopard" wrote:

> So, I'm a cut and paster when it comes to VBA, and I was able to modify this
> to use my tables to add to my default calendar. However, I don't want to add
> 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!ApptDate & " " & 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
> 'You can hard-wire in these dates or get the
> 'information from text boxes, as used here.
> '.PatternStartDate = #12/1/2003#
> .PatternStartDate = Me!ApptStartDate
> '.PatternEndDate = #12/30/2003#
> .PatternEndDate = Me!ApptEndDate
> End With
> .Save
> .Close (olSave)
> End With
> 'Release the AppointmentItem object variable.
> Set objAppt = Nothing
> End If
> 'Release the object variables.
> Set objOutlook = Nothing
> ....Set objRecurPattern = 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
>

 
Reply With Quote
 
David H
Guest
Posts: n/a
 
      21st Feb 2009
Actually you piqued my curiosity...

From what I can tell, you'll have to either use the .PickFolder method of
the namespace object to select the folder manually or loop through the
folders collection and choose it by a If...Then. (see
http://msdn.microsoft.com/en-us/library/bb177014.aspx) If you use the
technique in the article, you'll need to supply the full path.

Once you've selected (or found) the folder, you'll need to set an object
reference to the folders Items collection. Once instantiated, you'll then use
the .Add method of the Items collection to create the new AppointmentItem. I
don't know why, but you'd think that I'd remember something funky like that.

So in short, you won't be able to copy and past it. I did a fair amount of
googling around.


"Clddleopard" wrote:

> So, I'm a cut and paster when it comes to VBA, and I was able to modify this
> to use my tables to add to my default calendar. However, I don't want to add
> 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!ApptDate & " " & 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
> 'You can hard-wire in these dates or get the
> 'information from text boxes, as used here.
> '.PatternStartDate = #12/1/2003#
> .PatternStartDate = Me!ApptStartDate
> '.PatternEndDate = #12/30/2003#
> .PatternEndDate = Me!ApptEndDate
> End With
> .Save
> .Close (olSave)
> End With
> 'Release the AppointmentItem object variable.
> Set objAppt = Nothing
> End If
> 'Release the object variables.
> Set objOutlook = Nothing
> ....Set objRecurPattern = 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
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add appointment to calendar--NOT my default GMargen Microsoft Outlook VBA Programming 1 5th Mar 2009 02:17 PM
How to create an appointment item in a non-default calendar Jennifer Microsoft Outlook VBA Programming 4 20th Jun 2007 04:39 PM
Adding appointment to non default calendar Andy Pope Microsoft Outlook VBA Programming 6 14th Jun 2007 08:18 PM
Changing Calendar Appointment default. =?Utf-8?B?Uml0YQ==?= Microsoft Outlook Calendar 1 7th Jun 2006 10:17 PM
Appointment in NON-DEFAULT calendar Ciao Microsoft Access External Data 1 12th May 2004 07:43 AM


Features
 

Advertising
 

Newsgroups
 


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