L
Linda Fiske
Hello:
I have created ongoing one-week schedules in MS Word and want to have the
user type in the beginning date and have the rest of the date fields
populate from that. Here is a plain text version example of the table I
created.
July 30 [bookmark "firstDate] - August 3 [bookmark "lastDate"]
Monday 30 [bookmark "mon"]
Tuesday 31 [bookmark "tues"]
Wednesday 1 [bookmark "weds"}
Thursday 2 [bookmark "thurs"]
Friday 3 [bookmark "fri"]
I am having the user input the first date in a visual basic form with the
following :
visible textbox named firstDate
invisible textbox named lastDate
invisible textbox named mon
invisible textbox named tues
invisible textbox named weds
invisible textbox named thurs
invisible textbox named fri
command control named buttonPopulate
several labels
Here is the code:
Private Sub buttonPopulate_Click()
With ActiveDocument
.Bookmarks("firstDate").Range.InsertBefore firstDate
.Bookmarks("lastDate").Range.InsertBefore lastDate
.Bookmarks("mon").Range.InsertBefore mon
.Bookmarks("tues").Range.InsertBefore tues
.Bookmarks("weds").Range.InsertBefore weds
.Bookmarks("thurs").Range.InsertBefore thurs
.Bookmarks("fri").Range.InsertBefore fri
End With
UserForm1.Hide
End Sub
Private Sub firstDate_Change()
End Sub
Private Sub labelBegDate_Click()
End Sub
Private Sub labelDirections_Click()
End Sub
Private Sub lastDate_Change()
Dim lastDate As Date
Dim IntervalType As String
Dim Number As Integer
IntervalType = "d" ' "d" specifies days as interval.
lastDate = DateAdd(d, 5, firstDate)
End Sub
Private Sub mon_Change()
mon as date
mon = Day (firstDate)
End Sub
Private Sub tues_Change()
tues as date
tues = DateAdd(d, 1, firstDate)
Day(tues)
End Sub
Private Sub weds_Change()
weds as date
weds = DateAdd(d, 2, firstDate)
Day(weds)
End Sub
Private Sub thurs_Change()
thurs as date
thurs = DateAdd(d, 3, firstDate)
Day(thurs)
End Sub
Private Sub fri_Change()
fri as date
fri = DateAdd(d, 4, firstDate)
Day(fri)
End Sub
Private Sub UserForm_Click()
End Sub
I got the "firstDate" bookmark to populate, but none of the others. Am I
even on the right track? Any assistance anyone can offer would be very much
appreciated.
Thank you.
Linda
I have created ongoing one-week schedules in MS Word and want to have the
user type in the beginning date and have the rest of the date fields
populate from that. Here is a plain text version example of the table I
created.
July 30 [bookmark "firstDate] - August 3 [bookmark "lastDate"]
Monday 30 [bookmark "mon"]
Tuesday 31 [bookmark "tues"]
Wednesday 1 [bookmark "weds"}
Thursday 2 [bookmark "thurs"]
Friday 3 [bookmark "fri"]
I am having the user input the first date in a visual basic form with the
following :
visible textbox named firstDate
invisible textbox named lastDate
invisible textbox named mon
invisible textbox named tues
invisible textbox named weds
invisible textbox named thurs
invisible textbox named fri
command control named buttonPopulate
several labels
Here is the code:
Private Sub buttonPopulate_Click()
With ActiveDocument
.Bookmarks("firstDate").Range.InsertBefore firstDate
.Bookmarks("lastDate").Range.InsertBefore lastDate
.Bookmarks("mon").Range.InsertBefore mon
.Bookmarks("tues").Range.InsertBefore tues
.Bookmarks("weds").Range.InsertBefore weds
.Bookmarks("thurs").Range.InsertBefore thurs
.Bookmarks("fri").Range.InsertBefore fri
End With
UserForm1.Hide
End Sub
Private Sub firstDate_Change()
End Sub
Private Sub labelBegDate_Click()
End Sub
Private Sub labelDirections_Click()
End Sub
Private Sub lastDate_Change()
Dim lastDate As Date
Dim IntervalType As String
Dim Number As Integer
IntervalType = "d" ' "d" specifies days as interval.
lastDate = DateAdd(d, 5, firstDate)
End Sub
Private Sub mon_Change()
mon as date
mon = Day (firstDate)
End Sub
Private Sub tues_Change()
tues as date
tues = DateAdd(d, 1, firstDate)
Day(tues)
End Sub
Private Sub weds_Change()
weds as date
weds = DateAdd(d, 2, firstDate)
Day(weds)
End Sub
Private Sub thurs_Change()
thurs as date
thurs = DateAdd(d, 3, firstDate)
Day(thurs)
End Sub
Private Sub fri_Change()
fri as date
fri = DateAdd(d, 4, firstDate)
Day(fri)
End Sub
Private Sub UserForm_Click()
End Sub
I got the "firstDate" bookmark to populate, but none of the others. Am I
even on the right track? Any assistance anyone can offer would be very much
appreciated.
Thank you.
Linda