Close Task Window?

R

ryguy7272

Part of my code is pasted below:
Dim objApp As Object
Dim OutTask As Object

Set objApp = CreateObject("Outlook.Application")
Set OutTask = objApp.CreateItem(olTaskItem)
With OutTask
.StartDate = Cells(i, 5).Value
.Subject = Cells(j, 3).Value
.Body = Cells(k, 1).Value & " - " & Cells(l, 4).Value
.Importance = olImportanceHigh
.Display
.ReminderSet = True
'.ReminderTime = [NextPM]
'.DueDate = [NextPM]
'.ReminderPlaySound = True
'.ReminderSoundFile = "C:\WINNT\Media\Ding.wav"
.Save
.Close
End With

I created a loop to run through Excel and place certain data from certain
ranges into a series of Outlook Tasks. Everything works fine, I am just
trying to determine how to close the Task window once the data has been
populated into each Task. It must be something quite simple; just can't
quite figure it out. Please help.

Regards,
Ryan---
 
S

Sue Mosher [MVP-Outlook]

Both the .Display and .Close statements are unnecessary. You do not need to display an item in order to set its properties. Calling .Save is what does the trick.
 
R

ryguy7272

Awesome! One more question...a little off the original topic... How can I
prevent duplicates from being entered into the Task list? I may open the
Excel tool on Monday and update tasks for individuals. By the end of the
week, as some time has passed and new tasks are required, but some remain the
same (or may not be done until the following week, or instance), I want to
run the code again, but I don't want to enter the same name and time into my
Task list (because it is already there). I only want to enter the name and
time if the name and/or time is different. Can this be done? I am
controlling everything from Excel.

Regards,
Ryan—



--
RyGuy


Ken Slovak - said:
Close should do it.




ryguy7272 said:
Part of my code is pasted below:
Dim objApp As Object
Dim OutTask As Object

Set objApp = CreateObject("Outlook.Application")
Set OutTask = objApp.CreateItem(olTaskItem)
With OutTask
.StartDate = Cells(i, 5).Value
.Subject = Cells(j, 3).Value
.Body = Cells(k, 1).Value & " - " & Cells(l, 4).Value
.Importance = olImportanceHigh
.Display
.ReminderSet = True
'.ReminderTime = [NextPM]
'.DueDate = [NextPM]
'.ReminderPlaySound = True
'.ReminderSoundFile = "C:\WINNT\Media\Ding.wav"
.Save
.Close
End With

I created a loop to run through Excel and place certain data from certain
ranges into a series of Outlook Tasks. Everything works fine, I am just
trying to determine how to close the Task window once the data has been
populated into each Task. It must be something quite simple; just can't
quite figure it out. Please help.

Regards,
Ryan---
 
K

Ken Slovak - [MVP - Outlook]

Search the Items collection of that Tasks folder for existing items that
have the same criteria that you consider important to determine duplicates
before you add the new task item. Look in the Object Browser for the help on
the Items.Restrict method, that has examples of returning a restricted set
of items that meet your criteria. If the returned collection is empty (Count
= 0) then nothing matched and it's not a duplicate.
 

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