ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating task in outlook from a particular row in excel (https://www.excelbanter.com/excel-programming/405179-creating-task-outlook-particular-row-excel.html)

[email protected]

Creating task in outlook from a particular row in excel
 
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

Steve Yandl

Creating task in outlook from a particular row in excel
 
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



wrote in message
...
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





All times are GMT +1. The time now is 05:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com