Creating a macro to update dates in a word doc

7

77Debbie77

I am wondering if there is a way to create a macro that will chance the "Week
Ending" date and dates of the week when I open the document every Friday to
update the attendance. Thank you for your assistance.

DEPARTMENT: WEEK ENDING 10/12/07


10/08 10/09 10/10 10/11 10/12
10/13 10/14
EMPLOYEE EMP # MON TUES WED THURS FRI SAT SUN
 
D

Dave D-C

Something along the lines of (in ThisDocument):

Option Explicit

Private Sub Document_Open()
Dim zToday As Date, i%
zToday = Date
'[at this point you could make sure today is Friday]
Selection.TypeText "DEPARTMENT: WEEK ENDING " & Format(zToday,
"mm/dd/yy") & vbNewLine
Selection.TypeText "EMPLOYEE EMP #" & vbTab & "MON" & vbTab &
"etc." & vbNewLine
Selection.TypeText vbTab & vbTab
For i = -4 To 2
Selection.TypeText vbTab & Format(zToday + i, "mm/dd")
Next i
Selection.TypeText vbNewLine
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top