I am trying to export MS Outlook tasks into excel

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
******************************************************
 
B

Bob Phillips

Add a button to a toolbar?

Dim oCb As CommandBar
Dim oCtl As CommandBarPopup
Dim oCtlBtn As CommandBarButton

Set oCb = Application.CommandBars("Standard")
With oCb
Set oCtlBtn = .Controls.Add(Type:=msoControlButton)
oCtlBtn.Caption = "myButton"
oCtlBtn.FaceId = 29
oCtlBtn.OnAction = "TaskSummary"
End With


You will need to get rid of the parameter and maybe pick up that value from
a cell.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top