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

Tip: Looking for answers? Try searching our database.

Inserting Alternate Dates for Lotto Draws

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Patrick Curran - 23 May 2006 00:14 GMT
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
Doug Robbins - Word MVP - 23 May 2006 05:02 GMT
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

Signature

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

> Hi,
>     Can anyone here help me with a project I am attempting with MS Word. I
[quoted text clipped - 18 lines]
>
> Pat Curran
macropod - 23 May 2006 10:23 GMT
Hi Patrick,

You can also achieve the desired result with field coding. To see how to do
this and just about everything else you might want to do with dates in Word,
check out my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902

Cheers

> Hi,
>      Can anyone here help me with a project I am attempting with MS Word. I
[quoted text clipped - 18 lines]
>
> Pat Curran
Patrick Curran - 23 May 2006 22:44 GMT
Thanks Macropod - I'll spend some time with your attachment and let you know
how I get on.

Pat
> Hi Patrick,
>
[quoted text clipped - 35 lines]
>>
>> Pat Curran
 
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.