PDA

View Full Version : [SLEEPER:] Create a Macro from a Form



nsaint
02-07-2008, 06:26 PM
I have a piece of code that I have used in the past to check my "Task" that are scheduled and then will automatically generate an email when the task is due. What I would like to be able to do is code a configuration that will allow me to manage which tasks are handled via this code instead of having it hard-coded.

I thought maybe I could create a form that would write the Macro based on the variable I needed, but it may also be a good idea to be able to manage which of these reminders were set and which ones were not.

Any thoughts?

Here is the code;


Private Sub Application_Reminder(ByVal Item As Object)
Dim objMsg As MailItem
' create new outgoing message
If Item.Class = olTask Then
If Item.Subject = "My Task Header" Then
Set objMsg = Application.CreateItem(olMailItem)
' your reminder notification address
objMsg.To = "email_addr@sample.com"
objMsg.CC = "cc_myself@me.com"
objMsg.Subject = "Reminder: " & Item.Subject
objMsg.Body = Item.Body
objMsg.Send
End If
End If
Set objMsg = Nothing
End Sub