AUTOMATIC POP-UP FOR DEADLINES IN WORD DOC

ttp921

New Member
Joined
Sep 8, 2023
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hi all - I am very new to using Macros with Excel and I am looking for help. I am using code to attempt to automatically generate a word doc with upcoming deadlines/due dates in my Excel sheet. Currently, it will only generate a word doc if I manually run the code. Here's the code I am using:

Sub Due_Date()
Dim DueDate_Col As Range
Dim Due As Range
Dim PopUp_Notification As String
Set DueDate_Col = Range("J2:J500,D2:D500,D2:D500,M2:M500")
For Each Due In DueDate_Col
If Due <> "" And Date >= Due - Range("S2") Then
PopUp_Notification = PopUp_Notification & vbCrLf & Cells(Due.Row, "A") & " - " & Cells(1, Due.Column) & " - " & Due.Value
End If

Next Due
If PopUp_Notification = "" Then
MsgBox "No outstanding tasks/SOLs due."
Else
Dim WordApp As Object
Dim WDoc As Object
'
'Create Word.Application
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set WordApp = CreateObject("Word.Application")
Err.Clear
End If
On Error GoTo 0
WordApp.Visible = True
Set WDoc = WordApp.Documents.Add
WDoc.Range(0, 0).Text = PopUp_Notification
WordApp.Activate
End If
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top