.RemiderTime Won't Set Properly

D

digger27

I am trying to generate tasks in Outlook from excel/access based on various
activities in each. My problem is that I can't seem to get the .remindertime
to set to anything other than "12:00AM", no matter what I try. Any ideas?
My code for this section is below:

Private Sub CreatTask()
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olfolder As Outlook.MAPIFolder
Dim olTaskItem As Outlook.TaskItem
Dim strBodyText As String
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderTasks)
Set olTaskItem = olfolder.Items.Add("IPM.Task")
With olTaskItem
.DueDate = Date
.ReminderTime = Now() + 2
.Subject = "Rural Inspections " & Date$
.ReminderTime = Date + 1
.ReminderSet = True
.Categories = "Rural Projects"
.Save
End With
Set olTaskItem = Nothing
Set olfolder = Nothing
Set olNS = Nothing
Set olApp = Nothing
End Sub

I have tried using the following:
..ReminderTime = #2:00 PM#
..ReminderTime = "2:00 PM"
..ReminderTime = 2:00:00 PM
mytime = #2:00:00 PM#
..ReminderTime = mytime

None of these have worked. All of these return a time of 12:00 AM in the
task.

Any help would be appreciated.

Thanks in advance.
 
S

Sue Mosher [MVP-Outlook]

That's normal and expected behavior and cannot be overriddent. Task reminders have only dates, not specific times.
 
D

digger27

OK, so I found one problem with my code. I have .ReminderTime listed twice.
So, I made the change to look like this:
Private Sub CreateTask()
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olfolder As Outlook.MAPIFolder
Dim olTaskItem As Outlook.TaskItem
Dim strBodyText As String
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderTasks)
Set olTaskItem = olfolder.Items.Add("IPM.Task")
With olTaskItem
.DueDate = Date + 1
.Subject = "Rural Inspections " & Date$
.ReminderTime = #5:00:00 PM#
.ReminderSet = True
.Categories = "Rural Projects"
.Save
End With
Set olTaskItem = Nothing
Set olfolder = Nothing
Set olNS = Nothing
Set olApp = Nothing
End Sub

The only problem is that this sets the date to 12/30/1899. Any ideas?
 
D

digger27

Sue,
Thanks, but I don't understand how I can set the date with one set of code,
or set the date with another set of code, but not set both at the same time.
And if Task reminders don't have a time, how come I can set the reminder time
and date for a task manually and it will give me a reminder? I just want to
be able to set the date and time to a set interval beyond the time when the
code runs. Specifically, I want the .DueDate to be today's date and the
..ReminderTime to be either 2:00 PM or some interval (say 2 hours) past the
time the code runs. Are you saying that they both can't be set?
 
S

Sue Mosher [MVP-Outlook]

Let me take another look at that. I may have been thinking back a version or two.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
K

Ken Slovak - [MVP - Outlook]

Task reminders do have a time. Just kill the second reference where you use
Date as the source, which has no time, and use DateAdd("n", 2, Now) as your
ReminderTime setting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top