View Full Version : Import custom Outlook 2010 tasks from Excel 2010 using VBA

11-20-2013, 08:24 PM
I have a list of tasks in an Excel worksheet that includes custom fields that have already been created in Outlook. As an example, I have a custom task field named Project. I would like to import these tasks into Outlook. I keep getting the
Run-time error '91': Object variable or With block variable not set error. I have the following code:

Sub Test2()
Dim olApp As Outlook.Application
Dim olTask As Outlook.TaskItem
Dim olItem As Object
Dim myFields As Outlook.UserProperty

' Select cell A2, *first line of data*.

' Set Do loop to stop when an empty cell is reached.
Do Until IsEmpty(ActiveCell)
Set olApp = New Outlook.Application
Set olTask = olApp.CreateItem(olTaskItem)

With olTask

.UserProperties.Find("Project", True) = Cells(ActiveCell.Row, 2)
'.Subject = Cells(ActiveCell.Row, 5)
End With

Set olTask = Nothing
Set olApp = Nothing
'Step down 1 row from present location.
ActiveCell.Offset(1, 0).Select


End Sub

Any thoughts or ideas are welcome. Snarky comments are not. Please assume I've done my very best to search for answers before posting. Thank you!


11-21-2013, 01:53 AM
Have a look over here: