Export outlook task to Excel

Hi,
I tried to export outlook task in Excel by “File-Export option”.
But the field I created are not exported.
How can I export to excel, or import from excel all outlook task fields?
Thanks
Carol
Karl001Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Clark KentSoftware Engineer cum BloggerCommented:
Hello Karl,

I would like to tell you that Outlook does not export custom fields or user defined fields but you can do the rest of the thigns by following given method.

Open Outlook and follow the given instructions:

File >> Open >> Import >> Export to a File (Next) >> Comma Seperated Values (Windows - Next) >> Tasks (Next) >> Browse (to save CSV file) >> 

Feel free to ask further!!!

Regards
Clark Kent
Professor JMicrosoft Excel ExpertCommented:
you can manipulate task fields information with VBA.

BlueDevilFan has answered similar question on EE link is here http://www.experts-exchange.com/questions/23533230/VBA-to-export-Outlook-Tasks-to-Excel-worksheet.html

he also has a blog with very useful code exporting tasks from outlook to excel
Excel amusantCommented:
this is also another way to do it.


Select the tasks you want export in excel. (If you want to export all tasks then press "ctrl + A") to select all tasks in your tasks folder and then drag it to excel or you can copy (Ctrl + C) go to excel sheet and paste it there (Ctrl + v).

Best,
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Karl001Author Commented:
Hi ProfessorJimJam,

I tried to export my own tasks field, but It doesn't work.

Do you know if it's possible ?

Thanks,
Carol
Excel amusantCommented:
Hi,

The code is amended it will work. please copy the code and open outlook click (Alt + F11) insert a module and paste it.

The file will be saved in your desktop, File name Outlook Tasks.

before you run the code please ensure that microsoft Excel 14.0 object library is ticked as shown in the screen shot. to check click Tools--References .Microsoft-excel.PNG


[ Sub ExportTasks2Excel()
    Dim olkFolder As Outlook.MAPIFolder, _
        olkList As Outlook.Items, _
        olkTask As Outlook.TaskItem, _
        excApp As Object, _
        excBook As Object, _
        excSheet As Object, _
        intRow As Integer, _
        strQuery As String
    Set excApp = CreateObject("Excel.Application")
    Set excBook = excApp.Workbooks.Add
    Set excSheet = excBook.ActiveSheet
    intRow = 1
    Set olkFolder = Session.GetDefaultFolder(olFolderTasks)
    strQuery = "[DueDate] >= '6/1/2008' AND [DueDate] <= '12/31/2010'"
    Set olkList = olkFolder.Items.Restrict(strQuery)
    For Each olkTask In olkList
        excSheet.Cells(intRow, 1) = olkTask.Subject
        excSheet.Cells(intRow, 2) = olkTask.BillingInformation
        excSheet.Cells(intRow, 3) = olkTask.TotalWork
        excSheet.Cells(intRow, 4) = olkTask.StartDate
        excSheet.Cells(intRow, 5) = olkTask.DueDate
        excSheet.Cells(intRow, 6) = olkTask.Categories
        excSheet.Cells(intRow, 7) = olkTask.Role
        excSheet.Cells(intRow, 8) = olkTask.Body
        intRow = intRow + 1
    Next
    'Change the file path and name on the following line
    On Error Resume Next
    excBook.SaveAs "\\C:\Users\Public\Desktop\Outlook task.xlsx"
    excBook.Close False
    Set excSheet = Nothing
    Set excBook = Nothing
    Set excApp = Nothing
    Set olkTask = Nothing
    Set olkList = Nothing
    Set olkFolder = Nothing
End Sub
]
Excel amusantCommented:
'The file path is changed to user account:  "C:\Documents and Settings\" & UID & "\Outlook Tasks.xls" ' UID = User ID.

Sub ExportTasks2Excel()
    Dim olkFolder As Outlook.MAPIFolder, _
        olkList As Outlook.Items, _
        olkTask As Outlook.TaskItem, _
        excApp As Object, _
        excBook As Object, _
        excSheet As Object, _
        intRow As Integer, _
        strQuery As String
    Set excApp = CreateObject("Excel.Application")
    Set excBook = excApp.Workbooks.Add
    Set excSheet = excBook.ActiveSheet
    intRow = 1
    Set olkFolder = Session.GetDefaultFolder(olFolderTasks)
    strQuery = "[DueDate] >= '6/1/2008' AND [DueDate] <= '12/31/2010'"
    Set olkList = olkFolder.Items.Restrict(strQuery)
    For Each olkTask In olkList
        excSheet.Cells(intRow, 1) = olkTask.Subject
        excSheet.Cells(intRow, 2) = olkTask.BillingInformation
        excSheet.Cells(intRow, 3) = olkTask.TotalWork
        excSheet.Cells(intRow, 4) = olkTask.StartDate
        excSheet.Cells(intRow, 5) = olkTask.DueDate
        excSheet.Cells(intRow, 6) = olkTask.Categories
        excSheet.Cells(intRow, 7) = olkTask.Role
        excSheet.Cells(intRow, 8) = olkTask.Body
        intRow = intRow + 1
    Next
    'Change the file path and name on the following line
    UID = Environ("Username")
   
  
    excBook.SaveAs "C:\Documents and Settings\" & UID & "\Outlook Tasks.xls"
    
    excBook.Close False
    Set excSheet = Nothing
    Set excBook = Nothing
    Set excApp = Nothing
    Set olkTask = Nothing
    Set olkList = Nothing
    Set olkFolder = Nothing
End Sub

Open in new window

Karl001Author Commented:
Hi,

I  tested BlueDevilFan code gave by ProfessorJimJam, and it works.      
Excel amusant, it’s the same code as yours.

My problem is the result, I got only default task fields ( subject, billinginformation, ...) and not my custom  field.

As an example, I created  "ProjectName" custom field task.
In the code, I added the line:     excSheet.Cells(intRow, 9) = olkTask.ProjectName

And it doesn’t work, I got all others fields but not my custom field.
Excel amusantCommented:
Hi,

I have amended the code which was written by bluedevil as it was given error on line 17 and 34.

Please find below code the custom field ("ProjectName") is now included. I tested the code and it works perfectly.


Sub ExportTasks2Excel()

Dim objProperty As Outlook.UserProperty 'Defining the UDF Item

    Dim olkFolder As Outlook.MAPIFolder, _
        olkList As Outlook.Items, _
        olkTask As Outlook.TaskItem, _
        excApp As Object, _
        excBook As Object, _
        excSheet As Object, _
        intRow As Integer, _
        strQuery As String
    Set excApp = CreateObject("Excel.Application")
   
    Set excBook = excApp.Workbooks.Add
    Set excSheet = excBook.ActiveSheet
    intRow = 1
    Set olkFolder = Session.GetDefaultFolder(olFolderTasks)
    strQuery = "[DueDate] >= '6/1/2008' AND [DueDate] <= '12/31/2015'"
    Set olkList = olkFolder.Items.Restrict(strQuery)
    For Each olkTask In olkList
        excSheet.Cells(intRow, 1) = olkTask.Subject
        excSheet.Cells(intRow, 2) = olkTask.BillingInformation
        excSheet.Cells(intRow, 3) = olkTask.TotalWork
        excSheet.Cells(intRow, 4) = olkTask.StartDate
        excSheet.Cells(intRow, 5) = olkTask.DueDate
        excSheet.Cells(intRow, 6) = olkTask.Categories
        excSheet.Cells(intRow, 7) = olkTask.Role
        excSheet.Cells(intRow, 8) = olkTask.Body
        
        Set prop = olkTask.UserProperties.Item("ProjectName")
If Not (prop Is Nothing) Then
  excSheet.Cells(intRow, 9) = prop.Value
End If
        
        intRow = intRow + 1
    Next
    'Change the file path and name on the following line
    UID = Environ("Username")
   
  
    excBook.SaveAs "C:\Documents and Settings\" & UID & "\Outlook Tasks.xls"
    
    excBook.Close False
    Set excSheet = Nothing
    Set excBook = Nothing
    Set excApp = Nothing
    Set olkTask = Nothing
    Set olkList = Nothing
    Set olkFolder = Nothing
End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Karl001Author Commented:
Yeh! you made my day

Now I got in the exportation my custom field.

Thanks
Excel amusantCommented:
Glad that it was helpful:)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.