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 / February 2006

Tip: Looking for answers? Try searching our database.

How do I setup multiple automatic dates in a form field?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J. Lumsden - 03 Feb 2006 17:47 GMT
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

Rate this thread:






 
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.