![]() |
|
#1
|
||||
|
||||
![]() Quote:
A ContentControlOnExit macro to populate the calendar table from the first of your two calendar content controls (note the allocation of the "StartDate" title) is: Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Application.ScreenUpdating = False Dim CCtrlDate As Date, i As Long, j As Long, k As Long, Rng As Range If ContentControl.Title = "StartDate" Then CCtrlDate = CDate(ContentControl.Range.Text) i = CLng(CCtrlDate) - Format(CCtrlDate, "d") + 1 j = DateDiff("d", CCtrlDate, DateAdd("m", 1, CCtrlDate)) With ActiveDocument.Tables(2) Set Rng = .Range With Rng .Start = .Cells(9).Range.Start .Delete End With With .Range .Cells(1).Range.Text = "MONTH OF: " & Format(CCtrlDate, "MMMM, YYYY") For i = (i - 1) Mod 7 + 9 To .Cells.Count k = k + 1 .Cells(i).Range.Text = k If k = j Then Exit For Next End With End With End If Set Rng = Nothing Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
BoringDavid | Word VBA | 12 | 01-13-2014 02:40 AM |
Default dates for a Date Picker | BoringDavid | Word VBA | 2 | 09-11-2013 01:42 AM |
![]() |
Andy2011 | Word VBA | 4 | 11-24-2012 10:07 PM |
![]() |
nashville | Word | 16 | 04-06-2012 04:12 AM |
Date picker | trintukaz | Excel | 0 | 12-30-2011 12:42 AM |