Creating task in outlook from a particular row in excel

T

thecelebration

Hello,

I have a workbook with multiple worksheets, and I'd like to be able to
create tasks in Outlook based upon a selected row I highlight.

The worksheets have the same format, which is basically:

Task Name | Due Date | Category | Priority | X
| Y | Z
_________________________________________________________________
feed dog | March 1, 08| Pets | High |
a | b | c
do budget | March 9, 08| Finance | low |
a | b | c
fix car | May 3, 08 | Car | Med
| a | b | c


Now, I havent coded in VB before or created script in Excel...So was
curious if anyone has this already created and i can import easily.
Ideally would be great if there was a way i could highlight a row
above and then press a button at top which creates the outlook task.

any guidance appreciated!

thanks
s
 
S

Steve Yandl

Try something like this:

______________________________________

Sub TaskFromThisRow()
Const olFolderTasks = 13
Dim r As Integer
Dim P As Integer

r = ActiveCell.Row

Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")
Set olFolder = ns.GetDefaultFolder(olFolderTasks)

Set taskItem = olFolder.Items.Add
With taskItem
.Subject = ActiveCell.Worksheet.Cells(r, 1).Value
.DueDate = ActiveCell.Worksheet.Cells(r, 2).Value
.Categories = ActiveCell.Worksheet.Cells(r, 3).Value
If UCase(ActiveCell.Worksheet.Cells(r, 4).Value) = "HIGH" Then
P = 2
ElseIf UCase(ActiveCell.Worksheet.Cells(r, 4).Value) = "LOW" Then
P = 0
Else
P = 1
End If
.Importance = P
.Save
End With

Set taskItem = Nothing
Set ns = Nothing
Set ol = Nothing
End Sub

_______________________________________


Steve
 

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