>I can't figure out how to find the week number if a date is entered in
>Microsoft Word 2003. For example 1/1/2006 would be week 1. Excel has this
>feature(Weeknum) but I need to use it in word. Can anyone help me with this?
Use the Format function, using the ww format string as shown in the
VBA help topic "User-Defined Date/Time Formats (Format Function)".
Here's a little sample code:
MsgBox "Today is " & _
Format(Now, "dddd dd mmmm") & _
", in week " & _
Format(Now, "ww") & _
" of " & Format(Now, "yyyy")
If you need it as an integer instead of a string, you can use the CLng
function:
Dim wk As Long
wk = CLng(Format(Now, "ww"))
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
Carim - 07 Mar 2006 10:18 GMT
Hi,
Adapted from Macropod and Chip Pearson,
http://www.cpearson.com/excel/weeknum.htm
you could without VBA insert a field code :
{QUOTE
"{DATE \@ "d MMMM yyyy"} is Week "
{SET yd{={DATE \@ d}+INT(({DATE \@ M}-0.986)*30.575)-
IF({DATE \@ M}>2,2-(MOD({DATE \@ yy},4)=0)-
(MOD({DATE \@ yyyy},400)=0)-6+(MOD({DATE \@ yy},100)=0),0)}}
{=yd/7 \# 0}
."}
This field code will show both current date and week number.
HTH
Cheers
Carim
spalatty - 13 Apr 2006 14:46 GMT
Is there a way to convert a date already in the document into a week Number?
> >I can't figure out how to find the week number if a date is entered in
> >Microsoft Word 2003. For example 1/1/2006 would be week 1. Excel has this
[quoted text clipped - 22 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.