G
Guest
Dear All,
I am trying to export MS Outlook tasks into excel using the code below. I am
new to progamming and I would like to know how to call this procedure from a
command button from MS Excel. Here is the code:
******************************************************
Option Explicit
Sub TaskSummary(strImportance As String)
Dim olkApp As Outlook.Application
Dim nspNameSpace As NameSpace
Dim objTaskFolder As MAPIFolder
Dim objTask As Object
Set olkApp = CreateObject("Outlook.Application")
Set nspNameSpace = olkApp.GetNamespace("MAPI")
Set objTaskFolder = nspNameSpace.GetDefaultFolder(olFolderTasks)
Range("A5").Value = "Due Date"
Range("B5").Value = "Subject"
Range("C5").Value = "Status"
Range("A6").Select
For Each objTask In objTaskFolder.Items
If objTask.Status <> "Completed" Then
If objTask.Importance = strImportance Then
ActiveCell.Value = objTask.DueDate
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = objTask.Subject
ActiveCell.Offset(1, -1).Activate
End If
End If
Next
Columns("A:B").AutoFit
End Sub
Private Sub cmdUpdate_Click()
TaskSummary (objTask)
End Sub
******************************************************
I am trying to export MS Outlook tasks into excel using the code below. I am
new to progamming and I would like to know how to call this procedure from a
command button from MS Excel. Here is the code:
******************************************************
Option Explicit
Sub TaskSummary(strImportance As String)
Dim olkApp As Outlook.Application
Dim nspNameSpace As NameSpace
Dim objTaskFolder As MAPIFolder
Dim objTask As Object
Set olkApp = CreateObject("Outlook.Application")
Set nspNameSpace = olkApp.GetNamespace("MAPI")
Set objTaskFolder = nspNameSpace.GetDefaultFolder(olFolderTasks)
Range("A5").Value = "Due Date"
Range("B5").Value = "Subject"
Range("C5").Value = "Status"
Range("A6").Select
For Each objTask In objTaskFolder.Items
If objTask.Status <> "Completed" Then
If objTask.Importance = strImportance Then
ActiveCell.Value = objTask.DueDate
ActiveCell.Offset(0, 1).Activate
ActiveCell.Value = objTask.Subject
ActiveCell.Offset(1, -1).Activate
End If
End If
Next
Columns("A:B").AutoFit
End Sub
Private Sub cmdUpdate_Click()
TaskSummary (objTask)
End Sub
******************************************************