View Full Version : [SOLVED:] Schedule Tasks Every Nine WeekDays
MewRage
12-14-2013, 02:16 PM
I am completely new to Outlook and I want to use it as my agenda for school. I have a 9 day cycle and it doesn't apply to the weekends. And when I use the "Every x days" it sometimes lands on the weekends and that makes that my entire schedule is early by 2 days since we don't count the weekends but Outlook does. Can anyone help me with this? Thank you!
skatonni
12-16-2013, 02:27 PM
Try this
Sub Recurring_oddSchedule()
Dim oApptBase As AppointmentItem
Dim oAppt As AppointmentItem
Dim i As Long
Dim moreAppts As Long
Dim oddScheduleWorkingDays As Long
moreAppts = 10 '<-- Whatever more appts after the first you need
oddScheduleWorkingDays = 9
' Click on the first appointment
Set oApptBase = Application.ActiveExplorer.Selection.Item(1)
For i = oddScheduleWorkingDays To (oddScheduleWorkingDays * moreAppts) Step oddScheduleWorkingDays
Set oAppt = oApptBase.Copy
oAppt.Subject = "test"
oAppt.start = WorkingDays(i, oApptBase.start)
oAppt.Save
Debug.Print "Appt created: " & oAppt.start & "-" & oAppt.Subject
Next i
Set oApptBase = Nothing
Set oAppt = Nothing
Debug.Print " done"
End Sub
Private Function WorkingDays(NumDays As Long, startDate As Date) As Date
Dim Counter As Long
Dim ReturnDate As Date
Counter = NumDays
ReturnDate = startDate
Do While Counter > 0
ReturnDate = ReturnDate + 1
If Weekday(ReturnDate) >= 2 And Weekday(ReturnDate) <= 6 Then
Counter = Counter - 1
End If
Loop
WorkingDays = ReturnDate
End Function
Beginner help here http://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/
MewRage
12-16-2013, 04:52 PM
Thank you that works perfectly but I just need to know how can I modify it so that some days like lets say we have a break a week or something, hoe canI modify it to exclude those days?
Set moreAptts to the last date before the break, then run it again on the Appts after the break
MewRage
12-16-2013, 06:53 PM
Set moreAptts to the last date before the break, then run it again on the Appts after the break
Oh ok thank you!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.