2 Quick Ways to Insert the Days or Time Left before a Deadline in Your Word Document

In today’s article, we will present you 2 quick ways to insert the days or time left before a deadline in your Word document.

Every once in a while, when you are working on an important project, you will find that you have to keep in mind the exact days or time left before the deadline so as to adjust your working pace. Then it shall be a great idea to insert the days or time left before the deadline into your Word document, so they can remind you of the latest time left.

In the following text, we’d like to introduce you 2 methods of how to use macros to calculate and get the value.

Calculate Days Left before the Deadline

  1. First and foremost, place your cursor at the position where you want to insert the number.
  2. Then, click “Developer” tab.
  3. Next click “Visual Basic” in “Code” group to open the VBA editor. Also, you can press “Alt+ F11” instead in case “Developer” tab is not available in your Word.Click "Developer"->Click "Visual Basic"
  4. Now click “Normal” and then “Insert”.
  5. Next, choose “Module”.Click "Normal"->Click "Insert"->Click "Module"
  6. Double click the new module to open the editing area on the right side.
  7. Then paste the following codes there:
Sub CountDownfromTodayToDeadlineDate()
  Dim dtDeadlineDate As Date
  Dim lDaysLeft As Long

  '  Input the deadline date to calculate the date difference.
  dtDeadlineDate = InputBox("Enter the deadline date", "Deadline Date", "For example:2017/2/14") 
  lDaysLeft = DateDiff("d", Now, dtDeadlineDate)
 
  '  Output the date difference from today to the deadline date in word document. 
  Selection.Text = "There are " & lDaysLeft & " days left from today to " & dtDeadlineDate & vbCrLf
End Sub
  1. Next, click “Run” button.Paste Codes->Click "Run"
  2. You will be greeted with a dialog box, such as below:Enter Date ->Click "OK"

Enter the deadline date into the text box and click “OK”.Inserted Text Indicating Days Left

For easy use in the future, you can click “Macros” under “Developer” tab and choose the right macro then click “Run”. It shall trigger the dialog box.Click "Macros"->Choose the Right Macro->Click "Run"

Calculate Time Left before the Deadline

Sometimes, apart from getting days left, you may also need to know how much time you have left before a specific time. Then, the bellowing macro is what you will need.

  1. Repeat the first 8 steps above. Only you have to replace the codes with the following:
Sub CountDownfromNowToDeadlineTime()
  Dim dtTimeNow As Date
  Dim dtDeadlineTime As Date
  Dim lTimeLeft As Long
  Dim lHour As Long
  Dim lMinute As Long
  Dim lSecond As Long
 
  '  Get the time now and the deadline time.
  dtTimeNow = TimeValue(Now)
  dtDeadlineTime = InputBox("Enter the deadline time","Deadline Time", "For example:18:00:00") 
  '  Calculate the time difference.
  lTimeLeft = DateDiff("s", dtTimeNow, dtDeadlineTime)
  lHour = lTimeLeft \ 3600
  lTimeLeft = lTimeLeft - lHour * 3600
  lMinute = lTimeLeft \ 60
  lSecond = lTimeLeft - lMinute * 60
 
  Selection.Text = "There are " & lHour & " hours " & lMinute & " minutes " & lSecond & " seconds left from now to " & dtDeadlineTime & vbCrLf 
End Sub
  1. Remember to hit the “Run” button.Paste Codes->Hit "Run"
  2. This time, you will have the “Deadline Time” dialog box. Enter the deadline time then click “OK”.Enter Deadline Time->Click "OK"Time Left before Deadline

Keep Files Unharmed

To keep file integrity and store them away from corruption, the best and easiest way is to make backups often. However, we understand it’s hard to stick to a routine, which is why there are so many broken files every day. To repair these problematic files, you will need a corrupted Word repair tool.

Author Introduction:

Vera Chen is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including xlsx error repair tool and pdf repair software products. For more information visit www.datanumen.com

Leave a Reply

Your email address will not be published.