From: Michaelcip on
Using Word 2093. I have code, now I need it to place it into the table cell
so that it'll perform the code. Familiar w/ Access VBA, but discovered that
word is different. When the form opens the date of the ending Sunday will
populate into a cell (for time card form). Thanks, MC
From: Graham Mayor on
The macro will have to be triggered by some means. See the previous thread
and please keep to the one thread.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


"Michaelcip" <Michaelcip(a)discussions.microsoft.com> wrote in message
news:1EBDFEA7-2CC2-403F-A71D-A4FEB3A7B4BD(a)microsoft.com...
> Using Word 2093. I have code, now I need it to place it into the table
> cell
> so that it'll perform the code. Familiar w/ Access VBA, but discovered
> that
> word is different. When the form opens the date of the ending Sunday will
> populate into a cell (for time card form). Thanks, MC


From: Doug Robbins - Word MVP on
So what you have is a seven column table and in the first row of the table,
you want to put the days/dates of the week (which week, current week or next
week?) with Monday in the first column and Sunday in the last.

The following macro will do that, asking you if you want the dates for the
current week or the next week

Dim lag As Long
Dim Response
Select Case Format(Date, "ddd")
Case "Sun"
lag = 1
Case "Sat"
lag = 2
Case "Fri"
lag = 3
Case "Thu"
lag = 4
Case "Wed"
lag = 5
Case "Tue"
lag = 6
Case Else
lag = 0
End Select
Response = MsgBox("Do you want the dates for this week? Click Yes for this
week, No for next week.", vbYesNo + vbQuestion)
If Response = vbYes Then
lag = lag - 7
Else
lag = lag
End If
With ActiveDocument.Tables(1)
For i = 1 To 7
.Cell(1, i).Range.Text = Format(DateAdd("d", lag + i - 1, Date),
"dddd, dd/mm/yyyy")
Next i
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Michaelcip" <Michaelcip(a)discussions.microsoft.com> wrote in message
news:1EBDFEA7-2CC2-403F-A71D-A4FEB3A7B4BD(a)microsoft.com...
> Using Word 2093. I have code, now I need it to place it into the table
> cell
> so that it'll perform the code. Familiar w/ Access VBA, but discovered
> that
> word is different. When the form opens the date of the ending Sunday will
> populate into a cell (for time card form). Thanks, MC