Results 1 to 3 of 3
  1. #1
    sstiebinger is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    105

    Late Binding Outlook Tasks and Appointments

    Hi all, I have some code that I set up for sending tasks and appointments to Outlook that worked fine with Early Binding, and I'm now trying to convert this to Late Binding for compatibility between different office versions.

    Here's the current code:

    Code:
    Private Function isAppThere(appName) As BooleanOn Error Resume Next
        Dim objApp As Object
        isAppThere = True
        Set objApp = GetObject(, appName)
        If Err.Number <> 0 Then isAppThere = False
    End Function
    
    
    Private Sub cmdSendToOutlook_Click()
    On Error GoTo SendToOutlook_Err
        ' Save Record to be sure that required fields are filled
        If Me.Dirty Then Me.Dirty = False
        Dim outobj As Object
        If isAppThere("Outlook.Application") = False Then
            Set outobj = CreateObject("Outlook.Application")
        Else
            Set outobj = GetObject(, "Outlook.Application")
        End If
        ' Determine whether we're adding to Calendar or Tasks
        If Me.ActivityType = "Appointment" Then
            Dim outappt As Object
            Set outappt = outobj.CreateItem(1)
            With outappt
                .Start = Me.ActivityDate & " " & Me.ActivityTime
                .Duration = 60
                .Subject = Me.ActivityTitle
                .Body = Nz(Me.ActivityDetails, vbNullString)
                .ReminderMinutesBeforeStart = 60
                .ReminderSet = True
                .Save
            End With
            Set outappt = Nothing
        Else
            Dim outtask As Object
            Set outtask = outobj.CreateItem(3)
            With outtask
                .Subject = Me.ActivityTitle
                .Body = Nz(Me.ActivityDetails, vbNullString)
                .DueDate = Me.ActivityDate
                .Save
            End With
            Set outtask = Nothing
        End If
        ' Release Outlook object variable
        Set outobj = Nothing
        ' Save Record and display message
        If Me.Dirty Then Me.Dirty = False
        MsgBox "Sent to Outlook!"
        Exit Sub
    SendToOutlook_Err:
        MsgBox "Error " & Err.Number & vbCrLf & Err.Description
        Exit Sub
    End Sub
    When I create the appointment and click my button, I get the following error:

    Code:
    Error - 2147417851
    Method 'Subject' of object '_AppointmentItem' failed
    Googling this error shows others with similar problems, but they either are unresolved or their solutions don't fix my problem...



    Any ideas on what I did wrong? This code appears to be pretty identical to all of the examples I can find when googling Outlook Late Binding...

  2. #2
    sstiebinger is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    105
    Ok, so after a little more trial and error, I discovered that the code was not passing Me.ActivityTitle as a string.. I added
    Code:
    Dim strSubject As String
    strSubject = Me.ActivityTitle
    Then changed
    Code:
    .Subject = Me.ActivityTitle
    to
    Code:
    .Subject = strSubject
    and now my code works..... why that should make any difference when it worked fine with Early Binding... I don't know..

  3. #3
    sstiebinger is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    105
    .subject = me.activitytitle.value also works...

    Also had to use .value for .duedate in Tasks... go figure.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Access appointments to Outlook
    By IdleJack in forum Programming
    Replies: 8
    Last Post: 08-16-2019, 04:46 PM
  2. Replies: 4
    Last Post: 11-16-2014, 09:56 AM
  3. send outlook email with late binding
    By markjkubicki in forum Programming
    Replies: 3
    Last Post: 01-24-2014, 09:39 AM
  4. How do I achieve late binding on a Chart?
    By RocketMonkey in forum Forms
    Replies: 1
    Last Post: 02-12-2013, 02:11 PM
  5. Update/Delete Outlook appointments from Access
    By IdleJack in forum Programming
    Replies: 1
    Last Post: 09-12-2011, 03:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums