Results 1 to 3 of 3
  1. #1
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451

    add scheduled to outlook calendar

    I am working on a asset management database and looking at some future possibilities. I have a list of work to be scheduled and at this point I was just going to add a date and time to the list on my form, then sort it by "scheduled" not null to print out a report weekly but also got to thinking it would be nice if it would just populate an outlook calendar. I have done a little research and apparently it is very possible and am looking at the code below as an example to follow but my problem is that all of us at work use multiple calendars such as personal, the boss's, vacations and such. can I alter this code to go to a specific shared calendar? the author also has a pretty good video using it at https://www.youtube.com/watch?v=84TdF7cenzc



    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : btnAddApptToOutlook_Click
    ' DateTime  : 7/09/2009
    ' Author    : Patrick Wood
    ' Purpose   : Add an Access Appointment Record to the Outlook Calendar
    '---------------------------------------------------------------------------------------
    '
    Private Sub btnAddApptToOutlook_Click()
    'On Error GoTo ErrHandle
     
        Dim olNS As Object
        Dim olApptFldr As Object
     
        ' Save the Current Record
        If Me.Dirty Then Me.Dirty = False
     
        ' Exit the procedure if appointment has been added to Outlook.
        If Me.chkAddedToOutlook = True Then
            MsgBox "This appointment has already added to Microsoft Outlook.", vbCritical
            Exit Sub
        Else
     
            ' Use late binding to avoid the "Reference" issue
            Dim olApp As Object        'Outlook.Application
            Dim olAppt As Object        'olAppointmentItem
     
            'This is how we would do it if we were using "early binding":
    '        Dim olApp As Outlook.Application
    '        Dim olappt As Outlook.AppointmentItem
    '        Set olapp = CreateObject("Outlook.Application")
    '        Set olappt = olapp.CreateItem(olAppointmentItem)
     
            If isAppThere("Outlook.Application") = False Then
                ' Outlook is not open, create a new instance
                Set olApp = CreateObject("Outlook.Application")
            Else
                ' Outlook is already open--use this method
                Set olApp = GetObject(, "Outlook.Application")
            End If
     
            Set olAppt = olApp.CreateItem(1) ' 1 = olAppointmentItem
     
            ' Add the Form data to the Appointment Properties
            With olAppt
                If Nz(Me.chkAllDayEvent) = True Then
                    .AllDayEvent = True
     
                    ' Format the dates in the Form Controls
                    Me.txtStartDate = FormatDateTime(Me.txtStartDate, vbShortDate)
                    Me.txtEndDate = FormatDateTime(Me.txtEndDate, vbShortDate)
                    ' For all day events use "" for the start time and the end time
                    Me.cboStartTime = ""
                    Me.cboEndTime = ""
     
                    ' Get the Start and the End Dates
                    Dim dteTempEnd As Date
                    Dim dteStartDate As Date
                    Dim dteEndDate As Date
                    dteStartDate = CDate(FormatDateTime(Me.txtStartDate, vbShortDate)) ' Begining Date of appointment
                    dteTempEnd = CDate(FormatDateTime(Me.txtEndDate, vbShortDate))      ' Use to compute End Date of appointment
     
                    ' Add one day to dteEndDate so Outlook will set the number of days correctly
                    dteEndDate = DateSerial(Year(dteTempEnd + 1), Month(dteTempEnd + 1), Day(dteTempEnd + 1))
     
                    .Start = dteStartDate
                    .End = dteEndDate
     
                    ' Set the number of minutes for each day in the AllDayEvent Appointment
                    Dim lngMinutes As Long
     
                    lngMinutes = CDate(Nz(dteEndDate)) - CDate(Nz(dteStartDate))
                    ' The duration in Minutes, 1440 per day
                    lngMinutes = lngMinutes * 1440
     
                    ' Add the minutes to the Access Form
                    Me.txtApptLength.value = lngMinutes
     
                    .Duration = lngMinutes
     
                Else
                    ' The Validation Rule for the Start Date TextBox requires a
                    ' Start Date so there is no need to check for it here
                    If Len(Me.cboStartTime & vbNullString) = 0 Then
                        ' There is no end time on the Form
                        ' Add vbNullString ("") to avoid an error
                        Me.cboStartTime = vbNullString
                    End If
     
                    ' Set the Start Property Value
                    .Start = FormatDateTime(Me.txtStartDate, vbShortDate) _
                       & " " & FormatDateTime(Me.cboStartTime, vbShortTime)
     
                    ' If there is no End Date on the Form just skip it
                    If Len(Me.txtEndDate & vbNullString) > 0 Then
                        If Len(Me.cboEndTime & vbNullString) = 0 Then
                            ' There is no end time on the Form
                            ' Add vbNullString ("") to avoid an error
                            Me.cboEndTime = vbNullString
                        Else
                            ' Set the End Property Value
                            .End = FormatDateTime(Me.txtEndDate, vbShortDate) _
                               & " " & FormatDateTime(Me.cboEndTime, vbShortTime)
                        End If
                    End If
     
                    If Len(Me.txtApptLength & vbNullString) = 0 Then
                        Dim timStartTime As Date
                        Dim timEndTime As Date
     
                        ' Format the Start Time and End Time
                        timStartTime = FormatDateTime(Me.txtStartDate, vbShortDate) _
                               & " " & FormatDateTime(Me.cboStartTime, vbShortTime)
                        timEndTime = FormatDateTime(Me.txtEndDate, vbShortDate) _
                               & " " & FormatDateTime(Me.cboEndTime, vbShortTime)
     
                        .Duration = Me.txtApptLength
                    End If
                End If
     
                If Nz(Me.chkAllDayEvent) = False Then
                    .AllDayEvent = False
                End If
     
                If Len(Me.cboApptDescription & vbNullString) > 0 Then
                    .Subject = Me.cboApptDescription
                End If
     
                If Len(Me.txtApptNotes & vbNullString) > 0 Then
                    .Body = Me.txtApptNotes
                End If
     
                If Len(Me.txtLocation & vbNullString) > 0 Then
                    .Location = Me.txtLocation
                End If
     
                If Me.chkApptReminder = True Then
                    If IsNull(Me.txtReminderMinutes) Then
                        Me.txtReminderMinutes.value = 30
                    End If
                    .ReminderOverrideDefault = True
                    .ReminderMinutesBeforeStart = Me.txtReminderMinutes
                    .ReminderSet = True
                End If
     
                ' Save the Appointment Item Properties
                .Save
            End With
     
            ' Set chkAddedToOutlook to checked
            Me.chkAddedToOutlook = True
     
            ' Save the Current Record because we checked chkAddedToOutlook
            If Me.Dirty Then Me.Dirty = False
     
            ' Inform the user
            MsgBox "New Outlook Appointment Has Been Added!", vbInformation
        End If
     
    ExitHere:
        ' Release Memory
        Set olApptFldr = Nothing
        Set olNS = Nothing
        Set olAppt = Nothing
        Set olApp = Nothing
        Exit Sub
     
    ErrHandle:
        MsgBox "Error " & Err.Number & vbCrLf & Err.Description _
        & vbCrLf & "In procedure btnAddApptToOutlook_Click in Module Module1"
        Resume ExitHere
     
    End Sub
    
    '---------------------------------------------------------------------------------------
    ' Procedure : isAppThere
    ' Author    : Rick Dobson, Ph.D - Programming Microsoft Access 2000
    ' Purpose   : To check if an Application is Open
    ' Arguments : appName The name of the Application
    ' Example   : isAppThere("Outlook.Application")
    '---------------------------------------------------------------------------------------
    '
    Function isAppThere(appName) As Boolean
    On Error Resume Next
     
        Dim objApp As Object
     
        isAppThere = True
        Set objApp = GetObject(, appName)
        If Err.Number <> 0 Then isAppThere = False
    End Function

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Bing: access vba shared outlook calendar

    See if this helps:

    http://stackoverflow.com/questions/5...ples-calendars
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    thanks i'll look into that.

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

Similar Threads

  1. Populate Outlook calendar with Access Form
    By Artecy in forum Import/Export Data
    Replies: 1
    Last Post: 02-12-2014, 04:51 PM
  2. Populate outlook calendar from access
    By Don T in forum Access
    Replies: 5
    Last Post: 07-13-2013, 12:20 PM
  3. Need VBA code for adding to Outlook calendar
    By geraldk in forum Programming
    Replies: 3
    Last Post: 08-24-2012, 08:38 AM
  4. Access to Outlook Calendar
    By GregShah in forum Import/Export Data
    Replies: 1
    Last Post: 02-06-2012, 01:27 PM
  5. Access to Outlook Exchange Calendar
    By avarusbrightfyre in forum Import/Export Data
    Replies: 3
    Last Post: 01-31-2012, 01:49 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