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 / January 2005

Tip: Looking for answers? Try searching our database.

Create Sequential Dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg - 07 Jan 2005 20:08 GMT
Hello Teachers,

Today I spent some time trying to come up with a way to enter a
sequence of dates in a document.  Basically the OP had an Itenerary

Day 1  Jan 07, 2005
Day 2  Jan 08, 2005
etc.

I posted a solution where the user would run a macro to create a
collection of numbered DocVariables each storing the next days date.
Then in the document I inserted DocVariable fields with nested Quote
and Seq fields.

Day {Seq Date} { DocVariable{ Quote Var{ Seq dayNum }}
Day {Seq Date} { DocVariable{ Quote Var{ Seq dayNum }}
etc.

The macro to create the DocVariables follows:

Sub DateSeq()
Dim myDate As Date
Dim dayNum As Long
Dim numDays As Long

myDate = InputBox("Enter the start date in 1/31/2005 format.", "Start
On", Date)
numDays = InputBox("Enter the sequence length in days.", "Sequence
Length", "14")
For dayNum = 0 To numDays
ActiveDocument.Variables("Var" & dayNum).Value = Format(myDate +
dayNum - 1, "dddd, mmm d yyyy")
Next
ActiveDocument.Fields.Update
End Sub

I looked through the Google data base for anything close and didn't
seeing anything.  This seems to work, but I am to declare victory.  I
would appreaciate any comments on this method or suggestions for a
better method.

Thanks
Helmut Weber - 08 Jan 2005 15:26 GMT
Hi Greg,

I got no idea, what doc-variables are good for here,
and I hate fields anyway. I can do without them.

Sub Test001()
Dim i As Integer     ' just a counter
Dim DDiff As Integer ' interval date difference
Dim DStps As Integer ' steps to go
Dim Start As Date    ' the start date
Start = InputBox("Start dd.mm.yyyy") ' german
' no check provided
DDiff = InputBox("Interval")
DStps = InputBox("Steps")
Selection.TypeText Text:=Start & vbCr
For i = DDiff To DStps * DDiff Step DDiff
  Selection.TypeText Text:=Format(Start + i, "dd.mm.yyyy") & vbCr
  It's up to you where to insert the calculated date
Next
End Sub

Greetings from Bavaria,
a region in Europe,
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
Greg Maxey - 08 Jan 2005 15:56 GMT
Helmut,

Interesting.  Thanks.

The OP that I was helping apparently puts together interaries for his/her
travel club.

Apparently they are laid out

Day 1   Jan 1 2005
Do this
Day 2   Jan 2 2005
Do that
etc.

Uses SEQ fields to create the day number and was looking for a way to use a
similiar sequence for the date so that if Day2 was moved above Day1 a fields
update would sort out both day number and date.  The only thing I could
think of was to store the sequence of dates in numbered docvarialbes Var1
Var2 etc. and then display those dates in as sequenced docvariable fields.

Signature

Greg Maxey/Word MVP
A Peer in Peer to Peer Support

> Hi Greg,
>
[quoted text clipped - 23 lines]
> Word XP, Win 98
> http://word.mvps.org/
 
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.