|
Question : VBA Outlook.TaskItem Export Error
|
|
Ran into a problem with a long-running Access Macro which simply takes all of the Outlook task information from the local machine and exports it down into an Access table. I've narrowed the problem down to a specific task's .body item. This particular task previously had comment info in it but apparently it has now been deleted & my code below fails with the runtime error above on the line that gets the body info : "rst!Comments = c.Body" I've tried "... = nz(c.Body,"")" to no avail. It seems that the .body item for this task does not exist in the recordset or is not accessible to me. Do I need to check for it somehow first before trying to write it to my table or is there any other way to handle it?
Any help appreciated--thanks!
***************************************************************************** Dim ol As New Outlook.Application Dim olns As Outlook.NameSpace Dim cf As Outlook.MAPIFolder Dim c As Outlook.TaskItem Dim objItems As Outlook.Items Dim Prop As Outlook.UserProperty
Set olns = ol.GetNamespace("MAPI") Set cf = olns.GetDefaultFolder(olFolderTasks) Set objItems = cf.Items iNumTasks = objItems.Count
If iNumTasks <> 0 Then
For i = 1 To iNumTasks
If TypeName(objItems(i)) = "TaskItem" Then Set c = objItems(i) rst.AddNew rst!DueDate = c.DueDate rst!DoneDate = c.DateCompleted rst!DateUpd = c.LastModificationTime rst!Owner = c.Owner rst!Status = c.Status rst!Tabnq = c.Mileage rst!AccId = c.BillingInformation rst!Hours = c.TotalWork rst!Declined = c.DelegationState rst!Comments = c.Body rst.Update
End If Next i rst.Close End If
|
|
Answer : VBA Outlook.TaskItem Export Error
|
|
You might try checking it like this:
If Not c.Body Is Nothing Then rst!Comments = c.Body
or
Is Not IsNull(c.Body) Then rst!Comments = c.Body
|
|
|