Help please! Can't figure out how to automatically generate reports and include task description in the generated Excel 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. Also, I am having trouble getting the task description (Column N) generate automatically in my word doc report (Column N should correspond with Columns K-M). I hope someone can please help me. 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

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
This is a screenshot of the excel sheet I am using
 

Attachments

  • Excel Screenshot.png
    Excel Screenshot.png
    14.2 KB · Views: 9
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,183
Members
452,615
Latest member
bogeys2birdies

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