set outlook task through excel

G

goodfish

Hi,
I have adapted some code I found in JP site on setting outlook tasks through
excel.
I now make it happen on a change event however I have the following doubt.

Am I right in thinking the following code checks if outlook is open and
otherwise opens it. Because I get an error message when I run the code and
outlook is closed.

On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set olApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0

On the other hand if I add the following line after "End If"
olApp.Session.Logon
then I don't get the error message and although I don't see outlook opening
I do find the task when I open it manually.
Can someone please explain the above?
Thanks.
 
Top