"special" recuring appointment...

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

>
 
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.
Similar threads
Thread starter Title Forum Replies Date
P Outlook 2016 Change Paste Special Default Format Using Outlook 8
S vba outlook search string with special characters Outlook VBA and Custom Forms 1
S VBA search string with special characters Outlook VBA and Custom Forms 1
P Forwarding emails issue with special characters replacing text body Using Outlook 1
B Instant search with special characters Using Outlook 1
A "untitled attachment" if file name contains eg. special character Using Outlook 1
S automatically moving flagged sent e-mail to a special folder Outlook VBA and Custom Forms 1
J outlook 2007 special folders Using Outlook 1
G Outlook 2007 Macro: Paste - Paste Special - Unformatted Text Outlook VBA and Custom Forms 9
F Possible to restore/reinstall "special" buttons on custom form? Outlook VBA and Custom Forms 1
V VBA Categories unrelated to visible calendar and Visual appointment Categories Outlook VBA and Custom Forms 2
M using excel to sort outlook appointment items Outlook VBA and Custom Forms 4
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
B Linking contact to an Appointment Using Outlook 1
S Appointment font size when printing only changes Tasks' font Using Outlook 0
D Copy Appointment Body to Task Body Outlook VBA and Custom Forms 0
S New Outlook Appointment - Select All Body Text and Change Font and Size Outlook VBA and Custom Forms 1
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
Chiba Create an appointment for all the members Outlook VBA and Custom Forms 1
D Prevent popup of "Do you want to save changes?" when closing after opening an appointment to view Outlook VBA and Custom Forms 2
O Calendar - appointment templates and categories Using Outlook 1
W Appointment userproperties disappear Outlook VBA and Custom Forms 4
Nessa Can't create new appointment Using Outlook 1
F Appointment Show All Fields Using Outlook 1
C Trying to populate an appointment ComboBox from Excel Outlook VBA and Custom Forms 2
A Possible to hide ribbon with custom appointment form? Outlook VBA and Custom Forms 3
W Appointment occurrences change the location property Using Outlook 0
W Space in an Outlook appointment body Using Outlook 0
Dave A Run macro on existing appointment when it changes Outlook VBA and Custom Forms 1
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0
S Display PF contact folder items to select contact to link to appointment Outlook VBA and Custom Forms 1
M Forward Appointment as BCC with VBScript Outlook VBA and Custom Forms 7
K Update Appointment category when changed in Excel Using Outlook 3
S View Appointment in Text Wrap in Outlook 2007 Month Calendar View Using Outlook 0
A Day view - print appointment details Using Outlook 1
R Recover Deleted Appointment in Calendar Using Outlook 0
N Select Appointment subject line from combobox or list Outlook VBA and Custom Forms 1
S Appointment-Cannot set Categories because ConversationID is not set Outlook VBA and Custom Forms 1
D Record Appointment to Calendar on "Public Folder" Outlook VBA and Custom Forms 13
G Copy Contact field to Appointment Custom Form Field Outlook VBA and Custom Forms 2
G How to Copy Multi Select Listbox Data to Appointment Outlook VBA and Custom Forms 3
S Appointment colour categories disappear Using Outlook 4
G Using Data From Combo Box in Appointment Body Outlook VBA and Custom Forms 6
C Set reminder / appointment by right clicking email Using Outlook 1
A Add attachments to appointment based on field values Outlook VBA and Custom Forms 0
S how to set user properties to a newly created appointment Outlook VBA and Custom Forms 12
Y Creating custom appointment request form with multiple mail recipients Outlook VBA and Custom Forms 5
S my vbscript button1_click code works on appointment created but not on opening an existing apntmn Outlook VBA and Custom Forms 16
G Create an Appointment at the Contact's Address From Email Outlook VBA and Custom Forms 0
Diane Poremsky Create Task or Appointment and Insert Selected Text Using Outlook 0

Similar threads

Back
Top