![]() If (ContentControl.Title = "Visit Date - From") Then If Format(Str1, "YYYYMMDD") > Format(Str2, "YYYYMMDD") Then With ActiveDocument.SelectContentControlsByTitle("Visit Date - From")(1) With ActiveDocument.SelectContentControlsByTitle("Visit Date - To")(1) Try replacing all of the code in the document with: PlaceholderText Then Exit SubĪctiveDocument.CustomDocumentProperties("FromDt").Value = Format(, "MM/DD/YYYY")įor i = 0 To UBound(Split(.Range.Text, " "))Īfter that I am unable to get the calendar to appear.Īlso, is it possible for the code to run without the message boxes displaying. ![]() If (.Title = "Visit Date - From") Or (.Title = "Visit Date - To") Then Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)ĭim i As Long, j As String, Rng As Range, RngTmp As Rangeĭim CCtrl As ContentControl, Str1 As String, Str2 As String When I reset, the following line is highlighted:ĪctiveDocument.CustomDocumentProperties("ToDt").Value = Format(, "MM/DD/YYYY") Str2 = Format(.Item("FromDt").Value, "MM YYYY") Str1 = Format(.Item("ToDt").Value, "MM YYYY") With ActiveDocument.CustomDocumentProperties You are not allowed to edit this selection because it is protected. There are two things that happen when I set the dates a second time. Many thanks for the solution and getting back so quickly. If ActiveDocument.SelectContentControlsByTag("Visit_x0020_Date_x0020_x002d_x0020_From").Item(1).Range.Text = _ĪctiveDocument.SelectContentControlsByTag("Visit_x0020_Date_x0020_x002d_x0020_To").Item(1).Range.Text ThenĪny pointers would be really appreciated. I managed to compare the two fields, but that's only when the same date appears in both fields (pretty feeble attempt I know). Is it possible to achieve this through VBA? I thought I had cracked it by creating a calculated column in my sharepoint library using the formula:=IF(MONTH()=MONTH(),TEXT(,"DD"),TEXT(,"DD MMMM")) only to discover that you cannot insert calculated columns or values into a word document, at least not OOTB. dd - dd mmmm yyyy.īoth content controls in my word template are set to (dd mmmm yyyy). When the same month appears in the 'from date' and the 'to date', the format should be for example, 03 - 08 March 2014, i.e. ![]() When the month in the 'from date' is different to the month in the 'to date', the format should be for example, 03 March - 12 April 2014, i.e. The date format should appear as follows: I would like to change the format of the "Visit Date - From" depending on the dates entered in these two fields. The template has been set up as a content type for a sharepoint library, so the two date fields are entered via the document information panel. I have two date picker content controls ("Visit Date - From" and "Visit Date -To") in a Word template.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |