View Single Post
 
Old 05-21-2013, 11:15 AM
ofair ofair is offline Windows XP Office 2010 32bit
Novice
 
Join Date: May 2013
Posts: 1
ofair is on a distinguished road
Default Macro to DT Picker, but default to Weekdays

Hi,

I want to create a Macro that links two Content Controls. When the user selects the date in the first box, it appears again in the second box. If the user selects a Sunday or Saturday, The second box defaults to the Monday.

Right now I have:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim CCtrl As ContentControl, LngDt As Long
If ContentControl.Title <> "StartDate" Then Exit Sub
LngDt = CDate(ContentControl.Range.Text)
For Each CCtrl In ActiveDocument.ContentControls
  If CCtrl.Title = "EndDate" Then
  With CCtrl
    .LockContents = False
    .Range.Text = Format(LngDt, "DD MM YYYY")
    .LockContents = False
  End With
  
  ElseIf CDate(ContentControl.Range.Text) Mod 7 = 1 Then
  With CCtrl
    .LockContents = False
    .Range.Text = Format(Int(CDate(ContentControl.Range.Text) / 7) * 7 + 2, "DD MM YYYY")
    .LockContents = False
  End With
  
  End If
Next
End Sub
But the defaulting ends up happening to "StartDate" when I want it to happen to "EndDate". Any suggestions?
Reply With Quote