Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Document_ContentControlOnEnter(ByVal Endate As ContentControl)
- 'Declare variable names to deal with the content control data
- Dim SD As ContentControl
- Dim TC As ContentControl
- Dim TC1 As ContentControl
- Dim ED As ContentControl
- Dim NewDate
- 'Connect each variable name to its content control
- Set TC = ActiveDocument.SelectContentControlsByTag("Training").Item(1)
- Set SD = ActiveDocument.SelectContentControlsByTag("Stardate").Item(1)
- Set ED = ActiveDocument.SelectContentControlsByTag("Endate").Item(1)
- 'For some reason, twice removed from the source works better
- Set TC1 = TC
- If SD.Range.Text <> "Click to enter a date" Then
- NewDate = DateValue(SD.Range.Text)
- 'Look at Training Content Control - what was selected.
- 'If one of the two longer courses is picked, add 2 days to the start date
- 'and use that as the end date. Otherwise just add one day.
- Select Case TC1.Range.Text
- Case "Basic Skills"
- ED.Range.Text = Format((NewDate + 2), "MMM d, yyyy")
- Case "Caseworker"
- ED.Range.Text = Format((NewDate + 2), "MMM d, yyyy")
- Case Else
- ED.Range.Text = Format((NewDate + 1), "MMM d, yyyy")
- End Select
- End If
- 'Once we're done, re-set the variables for the next round. This does not change
- 'the content of the form.
- Set TC = Nothing
- Set SD = Nothing
- Set ED = Nothing
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement