"special" recuring appointment...

  • Thread starter Duncan McC
  • Start date Views 1,576
Status
Not open for further replies.
D

Duncan McC

Hi,

I found some code in this group that I'd like to use and modify to

create a recurring appointment, for:

* the 2nd Tuesday of every month, plus one day.

(This is to remind me to check server's n' stuff for MS monthly

updates).

In New Zealand though (17hrs ahead of the US approx), creating an

appointment for the 2nd *Wednesday* of every month, simply doesn't work

on a surprisingly often basis (eg. have a look at this month (April)).

So I want to create a recurring appointment for the 2nd Tuesday of every

month, plus one day (ie the next day after that).

Can the code below be mod'd to make this a go'er?

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

Duncan
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
I'd use the UI to create one appointment, then access it by code, and see

the values of the properties.

Best regards

Michael Bauer

Am Wed, 8 Apr 2009 15:23:38 +1200 schrieb Duncan McC:


> Hi,

> I found some code in this group that I'd like to use and modify to
> create a recurring appointment, for:
> * the 2nd Tuesday of every month, plus one day.

> (This is to remind me to check server's n' stuff for MS monthly
> updates).

> In New Zealand though (17hrs ahead of the US approx), creating an
> appointment for the 2nd *Wednesday* of every month, simply doesn't work
> on a surprisingly often basis (eg. have a look at this month (April)).

> So I want to create a recurring appointment for the 2nd Tuesday of every
> month, plus one day (ie the next day after that).

> Can the code below be mod'd to make this a go'er?

> 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
 
D

Duncan McC

Cheers Michael,

What is the line of code I need to access an appointment, say titled

"test001"?

TIA

Duncan

In article <1668c1s6xc25w.tuiulgpoiws7.dlg@40tude.net>, mb@mvps.org

says...

> I'd use the UI to create one appointment, then access it by code, and see
> the values of the properties.

>
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
If it's the current open item, you can access it this way:

Dim Appt as Outlook.AppointmentItem

Set Appt=Application.ActiveInspector.CurrentItem

Best regards

Michael Bauer

Am Thu, 9 Apr 2009 11:29:44 +1200 schrieb Duncan McC:


> Cheers Michael,

> What is the line of code I need to access an appointment, say titled
> "test001"?

> TIA
 
Status
Not open for further replies.
Top