G
Greg
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
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