|
|
|
date: Tue, 23 May 2006 00:14:16 +0100,
group: microsoft.public.word.vba.userforms
back
Re: Inserting Alternate Dates for Lotto Draws
Probably easiest way is to set up a spreadsheet in Excel in which you can
alter the start date and you have formulae in the column to return the other
dates that you want and then use mailmerge.
To do it with VBA, I would have an autonew macro in the template from which
you create the document display an input box into which the date of the
first Wednesday is entered by the user. Code in the macro would then create
document variables for each of the subsequent dates, and you would have
docvariable fields in the appropriate places in the template to display the
dates.
The code would be:
Dim i As Long
With ActiveDocument
.Variables("w1").Value = InputBox("Enter the date of the first Wednesday
in the format MM/dd/yy", "Lotto Dates")
.Variables("s1").Value = Format(DateAdd("d", 3, .Variables("w1").Value),
"MM/dd/yy")
For i = 2 To 10
.Variables("w" & i).Value = Format(DateAdd("d", (i - 1) * 7,
..Variables("w1").Value), "MM/dd/yy")
.Variables("s" & i).Value = Format(DateAdd("d", (i - 1) * 7,
..Variables("s1").Value), "MM/dd/yy")
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
"Patrick Curran" wrote in message
news:e4tgk7$h35$1@reader01.news.esat.net...
> Hi,
> Can anyone here help me with a project I am attempting with MS Word. I
> have an ten page document whereby I want to:
>
> 1) Insert a date range commencing with a Wednesday and ending on a
> Saturday covering an eight week period. The data needs to appear in pages
> 1 and 2 in the format "DD/MM/YY to DD/MM/YY". Can this be done by using an
> input form asking the question "What is the date of the first draw?
>
> 2) I then need to print the date of each of the eight draws commencing
> with the first Wednesday on page 3 and ending with draw eight on the last
> Saturday of the period on page 10.
>
> Lastly, I then need to print the document with the inserted dates at
> anytime during the period.
>
> I am only starting out with VBA so I would appreciate any help from list
> members.
>
> Thanks in Advance,
>
> Pat Curran
>
date: Tue, 23 May 2006 06:02:32 +0200
author: Doug Robbins - Word MVP
|
|