none
VBA Code correction for importing Tasks to Outlook from Excel RRS feed

  • Question

  • Hello Community,

    I am running a macro to import task from a Excel Table to Outlook. 

    It is working very fine if I add only two fields "Subject" and "Body"

    But when I tried to add more fields like "Categories", "Mileage", "Billing Information", "Companies", "Actual Work", "Status" ......It is showing an error "Object Doesn't Support this property or method"

    The part of the code is as below:

    'Add new items to the "Tasks" folder
        For i = 2 To NoA
            Set objTask = myItems.Add(olTaskItem)
                With objTask
                    .Subject = Cells(i, 1)
                    .Body = Cells(i, 2)
                    .Categories = Cells(i, 3)
                    .Mileage = Cells(i, 4)
                    .Billinginfomration = Cells(i, 5)
                    .Companies = Cells(i, 6)
                    .ActualWork = Cells(i, 7)
                    .Status = Cells(i, 8)
                    .Save
                End With
            Set objContact = Nothing
        Next

    I have a table from Column A to H with above information 

    Is it due to the Outlook 2007 which doesn't support all above fields or anything else.

    The Categories and other fields are there so must not be a cause of problem.

    Let me know the solution please.

    Monday, April 4, 2016 12:41 PM

Answers

  • Dhaval,

    The ActualWork property is stored in units of minutes. The ActualWork field on the standard task form is bound to the ActualWorkproperty; by default the field assumes an 8-hour day and 40-hour week.


    [custom.development]

    • Marked as answer by DhavalPaun Monday, April 4, 2016 6:37 PM
    Monday, April 4, 2016 6:20 PM

All replies

  • Hello Dhaval,

    What property causes an error exactly? Did you try to debug the code?

    Monday, April 4, 2016 5:24 PM
  • I corrected the code for status as below:

    'For Status
                    If Cells(i, 8).Value = "Completed" Then
            .Status = olTaskComplete

            ElseIf Cells(i, 8).Value = "In Progress" Then
            .Status = olTaskInProgress

            ElseIf Cells(i, 8).Value = "Deferred" Then
            .Status = olTaskDeferred

            ElseIf Cells(i, 8).Value = "Not Started" Then
            .Status = olTaskNotStarted

            ElseIf Cells(i, 8).Value = "Waiting on someone else" Then
            .Status = olTaskWaiting
            End If

    The error now I have is for "Actual Work"......Its getting imported but it shows as "1 Minute" instead of "1 Week"

    Need help on that

    Monday, April 4, 2016 5:27 PM
  • ActualWork property returns or sets the number of minutes. 1 week = 1 * 60 * 24 * 7 = 10080 minutes.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Monday, April 4, 2016 6:14 PM
  • Dhaval,

    The ActualWork property is stored in units of minutes. The ActualWork field on the standard task form is bound to the ActualWorkproperty; by default the field assumes an 8-hour day and 40-hour week.


    [custom.development]

    • Marked as answer by DhavalPaun Monday, April 4, 2016 6:37 PM
    Monday, April 4, 2016 6:20 PM