Hi William, Thanks for your response. I already thought if was something like that. However, I don't get it to work. I changed the days as you described but also wanted to make the notation shorter: Wk 01 instead of Week 01 and I want to get rid of the day numbering. I don't need it and I find it a bit distracting. I've tested in both 2004 and 2008 but in neither of them it's working. 2004 gives me the invalid date warning and in 2008 it does nothing at all.
(*
--------------------------------------------
Add Week Numbers 1.0
©2008 William Smith
[email protected]
This script may be freely modified for personal or commercial
purposes but may not be republished without prior consent.
If you find this script useful or have ideas for improving it, please let me know.
--------------------------------------------
This script adds a new all-day calendar event on every Sunday for the specified year.
Each event is set with a "Free" status and is named for the number of the week
and the ordinal date for the current year.
Installation: Place this script in your user home folder in this location
~/Documents/Microsoft User Data/Entourage Script Menu Items.
Use: Select "Add Week Numbers" from the Script menu in Entourage and enter a year
from 1905 to 2039. All-day Free status events will be added to each Sunday of the year
similar to the following information:
Wk 28
* )
-----------------------------------------------------------
-- Ask for a year - must between 1905 and 2039
-----------------------------------------------------------
tell application "Microsoft Entourage"
set theYear to ""
repeat until theYear ≥ 1905 and theYear ≤ 2039
set theYear to display dialog "This script will add week numbers to your default Entourage Calendar for the year below." default answer year of (current date) with icon 1 with title "Add week numbers for this year..."
set theYear to text returned of theYear
if theYear ≤ 1905 or theYear ≥ 2039 then
display dialog "Enter a year from 1905 to 2039." with icon 2 with title "Alert!"
end if
end repeat
end tell
-----------------------------------------------------------
-- What's the first day of the year?
-- Now, what's the first Sunday of the year?
-- This script will calculate week numbers
-- based on the first Sunday of the year.
-----------------------------------------------------------
set day1 to weekday of date ("January 1" & ", " & theYear)
if day1 is Monday then
set theSunday to 0
else if day1 is Tuesday then
set theSunday to -1
else if day1 is Wednesday then
set theSunday to -2
else if day1 is Thursday then
set theSunday to -3
else if day1 is Friday then
set theSunday to -4
else if day1 is Saturday then
set theSunday to -5
else if day1 is Sunday then
set theSunday to -6
end if
set newYearsDay to (date ("January 1" & ", " & theYear))
set firstSunday to newYearsDay + (86400 * theSunday)
-----------------------------------------------------------
-- Go populate the default calendar
-- with week numbers.
-----------------------------------------------------------
tell application "Microsoft Entourage"
make new event with properties {subject:"Wk 1", start time:firstSunday, all day event:true, recurring:false}
set oneWeek to 60 * 60 * 24 * 7 -- seconds x minutes x hours x days = one week
set weekNumber to 2
set dayNumber to theSunday + 8
repeat with i from 1 to 51
set nextSunday to (firstSunday) + (oneWeek * i)
make new event with properties {subject:"Wk " & weekNumber, start time:nextSunday, all day event:true, recurring:false}
set weekNumber to weekNumber + 1
end repeat
end tell
So William, what am I missing here? I hope you can help me out.