3 Kinds of Useful Reminders in Word Created via VBA

In this article, we would like to introduce you with 3 different kinds of reminders in Word which you can create via VBA.

Since some of us have to deal with a lot of files in Word on daily basis, we are likely to get dizzy with what to do and leave some jobs undone sometimes. In that case, a reminder shall be helpful. Therefore, we present you 3 sorts of handy reminders you can utilize to keep track of what to do.

The First Kind: The Daily Reminder

For example, if you prefer making plan for tomorrow at the end of today, a daily reminder is what you will need. In Word VBA editor, you can add a macro with the name “AutoExec”. Then each time you open Word application, the macro shall start running automatically and pop up a message box, pointing put all tasks to be finished in that day.

  1. Firstly, open Word and press “Alt+ F11” to open VBA editor.
  2. Then click “Normal”.
  3. Next click “Insert”.
  4. And choose “Module” on the menu to insert a new one under “Normal” project.Click "Normal"->Click "Insert"->Choose "Module"
  5. Now double click on the module to enter the editing area and paste the following codes there:
Sub AutoExec()
  Dim dtDate As Date
 
  dtDate = #2/20/2017#
  If Date = dtDate Then
    MsgBox "Tasks to be done today:" & vbCr & "1: Send fileXX to John Smith " & vbCr & "2: Finish file YY"
  End If
End Sub
  1. Next click “Save Normal” to save the change.Paste Codes->Click "Save Normal"

As a result, every time you open Word, there shall be a message box, listing all tasks you need to complete. By click “OK”, you can open and continue editing on a specific document.Daily Reminder

Notes:

  1. In code line “dtDate = #2/20/2017#”, the date is the day when you have to perform all the actions. Remember to change accordingly.
  2. In code line “MsgBox “Tasks to be done today:” & vbCr & “1: Send fileXX to John Smith ” & vbCr & “2: Finish file YY””, all contents between quotation marks is the task list you need to follow. Replace it with your own concrete missions. You should put each list item inside quotation marks and join it to the previous one with “& vbCr &” (no quotation marks).

The Second Kind: Reminders for Recurring Tasks

The Weekly Reminder

Here comes the weekly reminder, notifying things which you have to do on the same day every week.

  1. Firstly, repeat first 4 steps above.
  2. Only this time, you paste the bellowing macro:
Sub AutoExec()
  Dim dtWeekDay As Date

  dtWeekDay = vbMonday
 
  If dtWeekDay = Weekday(Date) Then
    MsgBox "Back up today of each week."
  End If
End Sub
  1. Similarly, click “Save Normal” button lastly.Paste Codes->Click the "Save Normal"

Likewise, there will be a message box. Click “OK” to go on writing in Word.The Weekly Reminder

Notes:

In code line “dtWeekDay = vbMonday”, you can change “vbMonday” to “vbTuesday”, “vbWednesday”, “vbThursday”, “vbFriday”, “vbSaturday”, or “vbSunday” accordingly.

The Monthly Reminder

In the same way, there is the monthly reminder, reminding you of monthly task.

  1. Still take the first 4 steps in “The First Kind: The Daily Reminder”.
  2. Then paste the codes there:
Sub AutoExec()
  Dim dtDay As Date

  dtDay = 20
 
  If dtDay = Day(Date) Then
    MsgBox "Back up today of each month."
  End If
End Sub
  1. Last but not the least, click “Save Normal”.Paste Monthly Codes->Click "Save Normal"

Similarly, a message box will pop up each time you open Word.The Monthly Reminder

Note:

In code line “dtDay = 20”, the number is the date when you need to fulfill the monthly task. Remember to alter it before run the macro.

The Third Kind: Reminders for Date or Time Difference

Considering there is a deadline for almost everything, it’s necessary to keep in mind the exact days or time left. Therefore, the coming 2 macros can automatically calculate the difference between the current date or time and the deadline date or time. And it’s visible when you open Word, showing the result in a message box.

The steps to run and save macro are the same as above.

Here is the macro to get the day difference:

Sub Autoexec()
  Dim dtDeadlineDay As Date
  Dim nDaysLeft As Long

  'Specify the deadline date and calculate the days left.
  dtDeadlineDay = #2/20/2017#
  nDaysLeft = DateDiff("d", Now, dtDeadlineDay)
 
  ' Show the days left before deadline.
  If nDaysLeft > 1 Then
    MsgBox "There are " & nDaysLeft & " days left before " & dtDeadlineDay & "."
  ElseIf nDaysLeft = 1 Then
    MsgBox "There is 1 day left before " & dtDeadlineDay & "."
  ElseIf nDaysLeft = 0 Then
    MsgBox "Today is the deadline!"
  End If
End Sub

And the result is:Day Difference

Note:

Remember to modify the code line “dtDeadlineDay = #2/20/2017#”. Just change the date as you need.

Then next is the macro to get the time difference:

Sub Autoexec()
  Dim dtCurrentTime As Date
  Dim dtDeadlineTime As Date
  Dim nTimeLeft As Long, nHour As Long, nMinute As Long, nSecond As Long
 
 
  ' Specify the current time and the deadline time.
  dtCurrentTime = TimeValue(Now)
  dtDeadlineTime = TimeValue("16:40:00 PM")
 
  ' Calculate and show the time difference.
  nTimeLeft = DateDiff("s", dtCurrentTime, dtDeadlineTime)
  nHour = nTimeLeft \ 3600
  nTimeLeft = nTimeLeft - nHour * 3600
  nMinute = nTimeLeft \ 60
  nSecond = nTimeLeft - nMinute * 60
 
  MsgBox "There are " & nHour & " hours " & nMinute & " minutes " & nSecond & " seconds left before " & dtDeadlineTime & "."
End Sub

And the outcome is:Time Difference

Note:

Replace the time in “dtDeadlineTime = TimeValue(“16:40:00 PM”)” with a meaningful one.

A Worthwhile Backup

We shall never under estimate the importance and what it can do after file gets corrupt. Besides, we are advised to come out a backup plan on a daily or weekly or monthly basis at least. Backup is the exact preparation we should make to prevent our data from damaged. Otherwise, the last-ditch effort we can spare is to obtain a corrupt Word data recovery tool.

Author Introduction:

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

Leave a Reply

Your email address will not be published. Required fields are marked *