Add Appointment to Outlook from Access 
Author Message
 Add Appointment to Outlook from Access

I am trying to get Access to add appointments to Outlook.  I found
Knowledge Base Article 209963:
http://www.*-*-*.com/ ;EN-US;Q209963

I've followed all the directions but am having a problem with the
code. (Code is shown below as well as in Article 209963).  I get this
error - Compile error: Argument not optional.  When I click ok, the
first line of the code is highlighted in yellow and .Close is selected
by the cursor.  I know nothing about Visual Basic so I have no clue
where to begin.  One other thing to note, in the instuctions it says:
"In the References dialog box, click to select the Microsoft Outlook
9.0 Object Library check box."  I only have Microsoft Outlook 10.0
Object Library.  I assume that is because I'm using Office XP.

Thank you for your help.

Private Sub cmdAddAppt_Click()
    On Error GoTo Add_Err

    'Save record first to be sure required fields are filled.
    DoCmd.RunCommand acCmdSaveRecord

    'Exit the procedure if appointment has been added to Outlook.
    If Me!AddedToOutlook = True Then
        MsgBox "This appointment is already added to Microsoft
Outlook"
        Exit Sub
    'Add a new appointment.
    Else
        Dim objOutlook As Outlook.Application
        Dim objAppt As Outlook.AppointmentItem

        Set objOutlook = CreateObject("Outlook.Application")
        Set objAppt = objOutlook.CreateItem(olAppointmentItem)

        With objAppt
            .Start = Me!ApptDate & " " & Me!ApptTime
            .Duration = Me!ApptLength
            .Subject = Me!Appt

            If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
            If Not IsNull(Me!ApptLocation) Then .Location =
Me!ApptLocation
            If Me!ApptReminder Then
                .ReminderMinutesBeforeStart = Me!ReminderMinutes
                .ReminderSet = True
            End If

            .Save
            .Close
            End With
            'Release the AppointmentItem object variable.
            Set objAppt = Nothing
    End If

    'Release the Outlook object variable.
    Set objOutlook = Nothing

    'Set the AddedToOutlook flag, save the record, display a message.
    Me!AddedToOutlook = True
    DoCmd.RunCommand acCmdSaveRecord
    MsgBox "Appointment Added!"

    Exit Sub

Add_Err:
    MsgBox "Error " & Err.Number & vbCrLf & Err.Description
    Exit Sub
End Sub



Wed, 24 Aug 2005 02:55:17 GMT  
 Add Appointment to Outlook from Access
Answered in Forms NewsGroup

--
Cheryl Fischer
Law/Sys Associates
Houston, TX


Quote:
> I am trying to get Access to add appointments to Outlook.  I found
> Knowledge Base Article 209963:
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q209963

> I've followed all the directions but am having a problem with the
> code. (Code is shown below as well as in Article 209963).  I get this
> error - Compile error: Argument not optional.  When I click ok, the
> first line of the code is highlighted in yellow and .Close is selected
> by the cursor.  I know nothing about Visual Basic so I have no clue
> where to begin.  One other thing to note, in the instuctions it says:
> "In the References dialog box, click to select the Microsoft Outlook
> 9.0 Object Library check box."  I only have Microsoft Outlook 10.0
> Object Library.  I assume that is because I'm using Office XP.

> Thank you for your help.

> Private Sub cmdAddAppt_Click()
>     On Error GoTo Add_Err

>     'Save record first to be sure required fields are filled.
>     DoCmd.RunCommand acCmdSaveRecord

>     'Exit the procedure if appointment has been added to Outlook.
>     If Me!AddedToOutlook = True Then
>         MsgBox "This appointment is already added to Microsoft
> Outlook"
>         Exit Sub
>     'Add a new appointment.
>     Else
>         Dim objOutlook As Outlook.Application
>         Dim objAppt As Outlook.AppointmentItem

>         Set objOutlook = CreateObject("Outlook.Application")
>         Set objAppt = objOutlook.CreateItem(olAppointmentItem)

>         With objAppt
>             .Start = Me!ApptDate & " " & Me!ApptTime
>             .Duration = Me!ApptLength
>             .Subject = Me!Appt

>             If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
>             If Not IsNull(Me!ApptLocation) Then .Location =
> Me!ApptLocation
>             If Me!ApptReminder Then
>                 .ReminderMinutesBeforeStart = Me!ReminderMinutes
>                 .ReminderSet = True
>             End If

>             .Save
>             .Close
>             End With
>             'Release the AppointmentItem object variable.
>             Set objAppt = Nothing
>     End If

>     'Release the Outlook object variable.
>     Set objOutlook = Nothing

>     'Set the AddedToOutlook flag, save the record, display a message.
>     Me!AddedToOutlook = True
>     DoCmd.RunCommand acCmdSaveRecord
>     MsgBox "Appointment Added!"

>     Exit Sub

> Add_Err:
>     MsgBox "Error " & Err.Number & vbCrLf & Err.Description
>     Exit Sub
> End Sub



Wed, 24 Aug 2005 04:33:10 GMT  
 Add Appointment to Outlook from Access
Someone pointed me to this newsgroup article.  The code in there
worked.
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=01bfa565%2449...
Quote:

> I am trying to get Access to add appointments to Outlook.  I found
> Knowledge Base Article 209963:
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q209963

> I've followed all the directions but am having a problem with the
> code. (Code is shown below as well as in Article 209963).  I get this
> error - Compile error: Argument not optional.  When I click ok, the
> first line of the code is highlighted in yellow and .Close is selected
> by the cursor.  I know nothing about Visual Basic so I have no clue
> where to begin.  One other thing to note, in the instuctions it says:
> "In the References dialog box, click to select the Microsoft Outlook
> 9.0 Object Library check box."  I only have Microsoft Outlook 10.0
> Object Library.  I assume that is because I'm using Office XP.

> Thank you for your help.

> Private Sub cmdAddAppt_Click()
>     On Error GoTo Add_Err

>     'Save record first to be sure required fields are filled.
>     DoCmd.RunCommand acCmdSaveRecord

>     'Exit the procedure if appointment has been added to Outlook.
>     If Me!AddedToOutlook = True Then
>         MsgBox "This appointment is already added to Microsoft
> Outlook"
>         Exit Sub
>     'Add a new appointment.
>     Else
>         Dim objOutlook As Outlook.Application
>         Dim objAppt As Outlook.AppointmentItem

>         Set objOutlook = CreateObject("Outlook.Application")
>         Set objAppt = objOutlook.CreateItem(olAppointmentItem)

>         With objAppt
>             .Start = Me!ApptDate & " " & Me!ApptTime
>             .Duration = Me!ApptLength
>             .Subject = Me!Appt

>             If Not IsNull(Me!ApptNotes) Then .Body = Me!ApptNotes
>             If Not IsNull(Me!ApptLocation) Then .Location =
> Me!ApptLocation
>             If Me!ApptReminder Then
>                 .ReminderMinutesBeforeStart = Me!ReminderMinutes
>                 .ReminderSet = True
>             End If

>             .Save
>             .Close
>             End With
>             'Release the AppointmentItem object variable.
>             Set objAppt = Nothing
>     End If

>     'Release the Outlook object variable.
>     Set objOutlook = Nothing

>     'Set the AddedToOutlook flag, save the record, display a message.
>     Me!AddedToOutlook = True
>     DoCmd.RunCommand acCmdSaveRecord
>     MsgBox "Appointment Added!"

>     Exit Sub

> Add_Err:
>     MsgBox "Error " & Err.Number & vbCrLf & Err.Description
>     Exit Sub
> End Sub



Wed, 24 Aug 2005 06:32:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Programatticaly add people to Outlook appointment created by function

2. Need VBA to add Appointment to Outlook XP

3. Add Appointment to Outlook from Website

4. Adding an Appointment to Outlook via VbScript

5. Deleting Outlook Appointment thru Access

6. Outlook -- New Appointments from Access

7. can't update Outlook appointments from access VBA code

8. How to access (export) tasks and appointments in OUTLOOK

9. How to access embedded appointments in appointment

10. Export | Import Outlook Appointments without Outlook

11. Automatically Adding Outlook Form Data to Access

12. Outlook Appointment by VBScript

 

 
Powered by phpBB® Forum Software