Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

finding the week number in word

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
spalatty - 07 Mar 2006 01:36 GMT
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?
Jay Freedman - 07 Mar 2006 02:19 GMT
>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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.