+ Reply to Thread
Results 1 to 7 of 7

Create Outlook task from Excel Macro?

  1. #1
    Jay Harris
    Guest

    Create Outlook task from Excel Macro?

    I want to know if I can create an Outlook task from an Excel macro. If so
    can someone help me learn to do this?

    Example of existing workbook:

    A B C D
    E

    4 Start date Task Name Description Length of task End
    Date

    5 Start date Task Name Description Length of task End
    Date

    6 Start date Task Name Description Length of task End
    Date



    I would want to have the macro read the "A" column and, if populated, create
    an Outlook 2003 task using the data in that row. This should be created for
    the currently logged in user. I do understand that script wanings may occur
    without something like Redemption, and that would be OK.



    Any help would be appreciated,

    Jay.Harris(at)removethis.cox.com





  2. #2
    Dick Kusleika
    Guest

    Re: Create Outlook task from Excel Macro?

    Jay

    Try here

    http://www.*****-clicks.com/excel/olTask.htm

    --
    **** Kusleika
    Excel MVP
    Daily Dose of Excel
    www.*****-blog.com

    Jay Harris wrote:
    > I want to know if I can create an Outlook task from an Excel macro.
    > If so can someone help me learn to do this?
    >
    > Example of existing workbook:
    >
    > A B C D E
    >
    > 4 Start date Task Name Description Length of task End
    > Date
    >
    > 5 Start date Task Name Description Length of task End
    > Date
    >
    > 6 Start date Task Name Description Length of task End
    > Date
    >
    >
    >
    > I would want to have the macro read the "A" column and, if populated,
    > create an Outlook 2003 task using the data in that row. This should
    > be created for the currently logged in user. I do understand that
    > script wanings may occur without something like Redemption, and that
    > would be OK.
    >
    >
    > Any help would be appreciated,
    >
    > Jay.Harris(at)removethis.cox.com




  3. #3
    Jay Harris
    Guest

    Re: Create Outlook task from Excel Macro?

    Thanks for the help, that is the right track...
    Now I have jut two issues left.
    First, I need to know how to pull the date out of the cell. When I try I get
    an run time error 13 type mismatch.
    Second, The other issue is how to get it to loop thruogh rows 4 to 30 and
    when there is a value in the correlating "A" column to create a task based
    on that rows data.

    Thanks again


    "**** Kusleika" <[email protected]> wrote in message
    news:[email protected]...
    > Jay
    >
    > Try here
    >
    > http://www.*****-clicks.com/excel/olTask.htm
    >
    > --
    > **** Kusleika
    > Excel MVP
    > Daily Dose of Excel
    > www.*****-blog.com
    >
    > Jay Harris wrote:
    >> I want to know if I can create an Outlook task from an Excel macro.
    >> If so can someone help me learn to do this?
    >>
    >> Example of existing workbook:
    >>
    >> A B C D E
    >>
    >> 4 Start date Task Name Description Length of task End
    >> Date
    >>
    >> 5 Start date Task Name Description Length of task End
    >> Date
    >>
    >> 6 Start date Task Name Description Length of task End
    >> Date
    >>
    >>
    >>
    >> I would want to have the macro read the "A" column and, if populated,
    >> create an Outlook 2003 task using the data in that row. This should
    >> be created for the currently logged in user. I do understand that
    >> script wanings may occur without something like Redemption, and that
    >> would be OK.
    >>
    >>
    >> Any help would be appreciated,
    >>
    >> Jay.Harris(at)removethis.cox.com

    >
    >




  4. #4
    Jay Harris
    Guest

    Re: Create Outlook task from Excel Macro?

    OK, I have resolved most of my issues...the last issues I have is, what do I
    do when it the loop hits a cell that is blank and it trys to create a task.
    It gives the run time error 13 type mismatch beacuse the DueDate field is
    reading from a blank cell in the workbook.

    Here is my Code:
    Private Sub CommandButton1_Click()

    Dim olApp As Outlook.Application
    Dim olTsk As TaskItem
    Dim w As Workbook
    Dim s As Worksheet
    Dim c As Range

    Set s = Worksheets("Project Timeline")
    Set olApp = CreateObject("Outlook.Application")

    For i = 4 To s.Range("A4").CurrentRegion.Rows.Count
    Set c = s.Cells(i, 1)
    Set olTsk = olApp.CreateItem(olTaskItem)

    With olTsk
    .StartDate = c.Value
    .Subject = c.Offset(0, 1).Value
    .Body = c.Offset(0, 2).Value
    .DueDate = c.Offset(0, 5).Value
    .Status = olTaskInProgress
    .Importance = olImportanceNormal
    .Display
    End With
    Next

    Set olTsk = Nothing
    Set olApp = Nothing

    End Sub

    When it hits the first line in which it finds a blank cell, it errors run
    time error 13 type mismatch. since I plan to give this spreadsheet to other
    members of my team this behavior is not perferred.

    Can anyone help?
    Thanks

    "**** Kusleika" <[email protected]> wrote in message
    news:[email protected]...
    > Jay
    >
    > Try here
    >
    > http://www.*****-clicks.com/excel/olTask.htm
    >
    > --
    > **** Kusleika
    > Excel MVP
    > Daily Dose of Excel
    > www.*****-blog.com
    >
    > Jay Harris wrote:
    >> I want to know if I can create an Outlook task from an Excel macro.
    >> If so can someone help me learn to do this?
    >>
    >> Example of existing workbook:
    >>
    >> A B C D E
    >>
    >> 4 Start date Task Name Description Length of task End
    >> Date
    >>
    >> 5 Start date Task Name Description Length of task End
    >> Date
    >>
    >> 6 Start date Task Name Description Length of task End
    >> Date
    >>
    >>
    >>
    >> I would want to have the macro read the "A" column and, if populated,
    >> create an Outlook 2003 task using the data in that row. This should
    >> be created for the currently logged in user. I do understand that
    >> script wanings may occur without something like Redemption, and that
    >> would be OK.
    >>
    >>
    >> Any help would be appreciated,
    >>
    >> Jay.Harris(at)removethis.cox.com

    >
    >




  5. #5
    Dick Kusleika
    Guest

    Re: Create Outlook task from Excel Macro?

    Jay

    You can just test for it. If it's empty do you want to skip the whole row?
    Is it if any cells are empty, or one in particular, or is just a blank row?

    These lines will skip the Task creation of the cell in column A is empty.


    > Set olApp = CreateObject("Outlook.Application")
    >
    > For i = 4 To s.Range("A4").CurrentRegion.Rows.Count
    > Set c = s.Cells(i, 1)


    If Not IsEmpty(c.Value) Then

    > Set olTsk = olApp.CreateItem(olTaskItem)
    >
    > With olTsk
    > .StartDate = c.Value
    > .Subject = c.Offset(0, 1).Value
    > .Body = c.Offset(0, 2).Value
    > .DueDate = c.Offset(0, 5).Value
    > .Status = olTaskInProgress
    > .Importance = olImportanceNormal
    > .Display
    > End With


    End If

    > Next
    >
    > Set olTsk = Nothing
    > Set olApp = Nothing
    >
    > End Sub
    >


    --
    **** Kusleika
    Excel MVP
    Daily Dose of Excel
    www.*****-blog.com



  6. #6
    Registered User
    Join Date
    08-04-2013
    Location
    Utah
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Create Outlook task from Excel Macro?

    Hey guys! Any thoughts on how might I modify this code so that it would only make a task if the value in one of the column is below a set number (ie 50)? Would there be anyway of altering the program so that it would recognize if there is already a task in outlook?

    Or is there a way that I could modify the code only to make a task from the selected row?

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Create Outlook task from Excel Macro?

    @indiegoober,

    Administrative Note:
    • Somebody would be happy to help with your query, but first, before we can proceed…
    • Please see Forum Rule #2...Do not post a question in the thread of another member -- start your own thread..
    • If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.
    • Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    HTH
    Regards, Jeff

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1