Consulting

Results 1 to 3 of 3

Thread: Problem with adding OL task code

  1. #1
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location

    Unhappy Problem with adding OL task code

    I am migrating over to new tablet pc's and to office 2010 and the following code now hangs with the message Run time 2147221227 (80040115)
    connection to microsoft exchange is unavailable, outlook must be online or connected to complete this action.
    Outlook is set to enable offline mode and the email script still works.
    Anything appear to be wrong with the code for 2010?

    Thanks...



    [VBA]Sub Tasks()
    Const olAppointmentItem As Long = 1
    Const olTaskItem As Long = 3
    Dim olApp As Object
    Dim OLNS As Object
    Dim OLTask As Object

    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    If olApp Is Nothing Then Set olApp = CreateObject("Outlook.Application")
    On Error GoTo 0

    If Not olApp Is Nothing Then

    Set OLNS = olApp.GetNamespace("MAPI")
    OLNS.Logon

    Set OLTask = olApp.CreateItem(olTaskItem)
    OLTask.Subject = Sheets("Visit Types").Range("b31").Value
    OLTask.Body = Sheets("Visit Types").Range("b32").Value
    OLTask.StartDate = Sheets("Visit Types").Range("b33").Value
    OLTask.DueDate = Sheets("Visit Types").Range("b34").Value
    OLTask.ReminderTime = Sheets("Visit Types").Range("b35").Value
    OLTask.display
    OLTask.Save

    Set OLTask = Nothing
    Set OLNS = Nothing
    Set olApp = Nothing
    End If

    End Sub[/VBA]

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    hi.
    code works fine for me with xl2010 & ol2010.

    here is the ms kb article for "connection to microsoft exchange is unavailable" error.

    http://support.microsoft.com/kb/2006508
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location
    Excellent, Thanks mancubus.
    I will let you know if that was the issue.
    Changing hardware and Office 2003 to 2010 at the same time

Posting Permissions

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