Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-19-2022, 09:22 AM
CellCharger CellCharger is offline Add 30 days based on another date Windows 10 Add 30 days based on another date Office 2019
Novice
Add 30 days based on another date
 
Join Date: Oct 2021
Location: NJ, USA
Posts: 24
CellCharger is on a distinguished road
Default

Thank you macropod for your support.

Yes, "Date of Initiation" is a Date Picker Content Control

The field that is supposed to add 30 days from date of initiation is called "Due Date".

I am not sure what should be the "Due Date" field type. I added a Rich Text Content Control (I am not sure if this should be another field type). So I changed the code to this:

Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim Dt As Date, StrDt As String
With CCtrl
  If .Title <> "Date of Initiation" Then Exit Sub
  If .ShowingPlaceholderText = True Then
    ActiveDocument.SelectContentControlsByTitle("Due Date")(1).Range.Text = ""
  Else
    StrDt = .Range.Text
    If IsDate(StrDt) Then
      Dt = CDate(StrDt)
    Else
      Dt = CDate(Split(StrDt, (Split(StrDt, " ")(0)))(1))
    End If
    ActiveDocument.SelectContentControlsByTitle("Due Date")(1).Range.Text = Format(Dt + 30, .DateDisplayFormat)
  End If
End With
Application.ScreenUpdating = True
End Sub
The problem now is that there is no macro to run. I am sorry If I missed something.



Also, can the due date field be automatically calculated without having to run a macro?
Reply With Quote
  #2  
Old 07-19-2022, 04:40 PM
macropod's Avatar
macropod macropod is offline Add 30 days based on another date Windows 10 Add 30 days based on another date Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by CellCharger View Post
I am not sure what should be the "Due Date" field type. I added a Rich Text Content Control (I am not sure if this should be another field type).
As per the advice I gave:
Quote:
Originally Posted by macropod View Post
where 'StartDate' is the title of your date-picker content control and 'OffsetDate' is the title of a text content control used for the output.
your "Due Date" (which is not a field in Word parlance) should be either a plain text content control or a rich text content control.
Quote:
Originally Posted by CellCharger View Post
The problem now is that there is no macro to run. I am sorry If I missed something.
Did you add the macro to the 'ThisDocument' module of the document or its template? It won't work if you put it in a different module.
Quote:
Originally Posted by CellCharger View Post
Also, can the due date field be automatically calculated without having to run a macro?
Not when using content controls. It is possible when using formfields in a protected document, but there is no date-picker formfield.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
If date is Current Month 1 or within 30 days Sje Excel 3 09-30-2019 10:40 PM
Add 30 days based on another date Create a calendar based on shifts not days lwlewis367 Project 1 11-04-2016 09:59 AM
Add 30 days based on another date Date field - future date calculation + only business days neon4 Word 7 01-21-2016 02:21 PM
Add 30 days based on another date adding days to a date euterpia Excel 1 01-18-2016 07:42 AM
Add 30 days based on another date Date Field to add 10 Days to Current Date Erbwon Word 6 11-12-2012 06:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft