Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Private Sub Document_ContentControlOnEnter(ByVal Endate As ContentControl)
  2.  
  3. 'Declare variable names to deal with the content control data
  4. Dim SD As ContentControl
  5. Dim TC As ContentControl
  6. Dim TC1 As ContentControl
  7. Dim ED As ContentControl
  8. Dim NewDate
  9.  
  10. 'Connect each variable name to its content control
  11. Set TC = ActiveDocument.SelectContentControlsByTag("Training").Item(1)
  12. Set SD = ActiveDocument.SelectContentControlsByTag("Stardate").Item(1)
  13. Set ED = ActiveDocument.SelectContentControlsByTag("Endate").Item(1)
  14. 'For some reason, twice removed from the source works better
  15. Set TC1 = TC
  16.  
  17. If SD.Range.Text <> "Click to enter a date" Then
  18. NewDate = DateValue(SD.Range.Text)
  19.  
  20. 'Look at Training Content Control - what was selected.
  21. 'If one of the two longer courses is picked, add 2 days to the start date
  22. 'and use that as the end date. Otherwise just add one day.
  23. Select Case TC1.Range.Text
  24. Case "Basic Skills"
  25. ED.Range.Text = Format((NewDate + 2), "MMM d, yyyy")
  26. Case "Caseworker"
  27. ED.Range.Text = Format((NewDate + 2), "MMM d, yyyy")
  28. Case Else
  29. ED.Range.Text = Format((NewDate + 1), "MMM d, yyyy")
  30. End Select
  31. End If
  32.  
  33. 'Once we're done, re-set the variables for the next round. This does not change
  34. 'the content of the form.
  35. Set TC = Nothing
  36. Set SD = Nothing
  37. Set ED = Nothing
  38.  
  39. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement