I'm attempting to setup automatic dates in a form field for a time sheet I'm
working on. These are submitted on Fridays, so I can auto date the Friday,
but I would like to be able to work backwards to auto date Mon-Thurs. How can
this be done?
Thanks,
J Lumsden
Dave Lett - 03 Feb 2006 18:47 GMT
Here's version of what I use:
Public Sub Main()
Dim sPath As String
Dim oDocCurWeek As Document
sPath = "H:\Weekly Reports\"
Set oDocCurWeek = ActiveDocument
With oDocCurWeek
.SaveAs FileName:=sPath & "Weekly Status Report " & fReportPeriod
Set oRng = oDocCurWeek.Bookmarks("ReportPeriod").Range
oRng.Text = fReportPeriod
oDocCurWeek.Bookmarks.Add Name:="ReportPeriod", Range:=oRng
End With
End Sub
Public Function fReportPeriod() As String
Dim dFirstDayOfWeek As Date
Dim dCurrDayOfWeek As Date
Dim sReportPeriod As String
dFirstDayOfWeek = DateAdd(Interval:="d", _
Number:=-(Weekday(Date:=Date, FirstDayOfWeek:=vbMonday) - 1), _
Date:=Date)
dCurrDayOfWeek = Date
sReportPeriod = Day(Date:=dFirstDayOfWeek) & "-" & Day(Date:=dCurrDayOfWeek)
If fMonthName(dDate:=dFirstDayOfWeek) = _
fMonthName(dDate:=dCurrDayOfWeek) Then
fReportPeriod = fMonthName(dDate:=dFirstDayOfWeek) & " " & _
sReportPeriod
Else
fReportPeriod = fMonthName(dDate:=dFirstDayOfWeek) & " " _
& Day(Date:=dFirstDayOfWeek) & "-" & _
fMonthName(dDate:=dCurrDayOfWeek) & " " _
& Day(Date:=dCurrDayOfWeek)
End If
End Function
Public Function fMonthName(dDate As Date) As String
fMonthName = MonthName _
(Month:=DatePart("m", Date:=dDate), _
Abbreviate:=True)
End Function
HTH,
Dave
> I'm attempting to setup automatic dates in a form field for a time sheet I'm
> working on. These are submitted on Fridays, so I can auto date the Friday,
[quoted text clipped - 3 lines]
> Thanks,
> J Lumsden
Greg - 03 Feb 2006 18:54 GMT
J.,
I believe that you could use my Date Sequencer Add-In for this task:
http://gregmaxey.mvps.org/Date_Sequencer.htm
Graham Mayor - 04 Feb 2006 07:28 GMT
You might like to look at Macropod's work on date fields linked from
http://www.gmayor.com/insert_a_date_other_than_today.htm

Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> I'm attempting to setup automatic dates in a form field for a time
> sheet I'm working on. These are submitted on Fridays, so I can auto
[quoted text clipped - 3 lines]
> Thanks,
> J Lumsden