Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Feb 2005
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Custom forms (2003)

    I have created an Access database that can read and write to Outlook's calendar - that is, it can create meetings. However, to be able to successfully interact, it really needs another field in the Meetings form.

    I have created a form based upon the meetings template within Outlook and have set it to be the default form. However, whenever a meeting is created in Access, the old default form is used by Outlook. Does anyone know how to completely supercede the old form so that new will be used at all times and the old (previous default) will never again be used?

    Thank you

    Robin

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Custom forms (2003)

    Hi Robin,
    When you add the item to the calendar folder, you need to specify the message class associated with your custom form - generally this will be of the format "IPM.Appointment.FormNameHere", so your code would have something like:
    <pre>Set oAppointment = fdrCalendar.Items.Add("IPM.Appointment.myCalendarF orm")
    </pre>

    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Custom forms (2003)

    If you delete some of those = signs, less horizontal scrolling will be required for Loungers using medium sized fonts. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    How many calendars are there? Or, more to the point, do you want to add the appointment to the user's default calendar? There is a method that obtains a reference to the default calendar named GetDefaultFolder. You can plug it in as follows:

    Dim fdrCalendar as Outlook.MAPIFolder
    Set fdrCalendar = objOutlook.GetNamespace("MAPI").GetDefaultFolder(o lFolderCalendar)
    Set objAppt = fdrCalendar.Items.Add("IPM.Appointment.NewAppointm ent")

    Or, to avoid creating an extra object that you might not need:

    Set objAppt = objOutlook.GetNamespace("MAPI").GetDefaultFolder(o lFolderCalendar).Items.Add("IPM.Appointment.NewApp ointment")

    Note: I didn't actually test this, but I looked in the help and believe it should work. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  4. #4
    New Lounger
    Join Date
    Feb 2005
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom forms (2003)

    Thanks Rory for your help.

    Sorry about the = signs. I copied it straight from my 19" flat screen monitor which obviously doesn't wrap these.

    I am going to put the last line you sent
    objOutlook.GetNamespace("MAPI").GetDefaultFolder(o lFolderCalendar).Items.Add("IPM.Appointment.NewApp ointment")
    into my code tomorrow when I get back to work.

    However, I have looked in Outlook help, Outlook VBA help, Access VBA help for, for example, GetDefaultFolder, but can't find a reference to that at all.

    My frustration is that somewhere, probably somewhere bloody obvious, is the description of the object model that explains the ".GetNamespace("MAPI").GetDefaultFolder(olFolderCa lendar).Items.Add("IPM.Appointment." part of this line of code in its logical symmetry. Just where does one go to get it or what do I have to do to find this?

    Cheers

    Robin

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Custom forms (2003)

    A lot of the overall structure of the Outlook object model is steeped in mystery. Sometimes properties and methods belong to the Application, and sometimes to the MAPI namespace. If you highlight a property or method name in the VB Editor and press F1, you should get the details for that particular item. If you don't know what you're looking for, however, it is more difficult. Sometimes it is earlier to search using the Object Browser (F2) for seemingly relevant terms, then highlight and press F1 for more details.

  6. #6
    New Lounger
    Join Date
    Feb 2005
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Custom forms (2003)

    Edited by HansV to "delete some of those = signs"

    Thanks Rory,

    That has helped somewhat.

    My problem is that I don't really yet understand the Outlook model and thus cannot relate to it properly at all.

    So far, what I have in Access to write to Outlook is this:

    Public Function fnAddOutlookAppt(lngApptID As Long, dtDate As Date, dtStartTime As Date, dtEndTime As Date, Optional strSubject As String, _
    Optional strLocation As String, Optional blReminder As Boolean, Optional intReminderMinutes As Integer, Optional strNotes As String) As Boolean

    '================================================= ============================
    'Purpose: Inserts the appointment into Outlook (sub AddDBAppt inserts the data into the database
    'Inputs: Date, Start Time, End Time, Subject, Location, Reminder, Reminder Minutes, Notes
    'Returns: True if successful, false if not
    'Notes:
    '================================================= =============================

    Dim objOutlook As Outlook.Application
    Dim objAppt As Outlook.AppointmentItem

    On Error GoTo ErrHandler

    Set objOutlook = CreateObject("Outlook.Application")

    'then what I did (just to prove my incomprehension of the subject) was to take your line of code and place it here

    Set objAppt = fdrCalendar.Items.Add("IPM.Appointment.NewAppointm ent")

    'Of course there is not reference to fdrCalendar and thus an error is formed and I don't know how to do it. I have tried but nothing makes sense. Would you mind helping me out on this and also, could you point me to a book(s) or references that can help this bear of little brain to gain some understanding of the Outlook object model so that I can get up to speed on this matter.

    What comes after this, thanks to Hans of the Access forum (and a little of my effort) is this

    With objAppt
    .Start = dtDate & " " & dtStartTime
    .End = dtDate & " " & dtEndTime
    If strSubject & " " = " " Then
    .Subject = "Access generated Meeting"
    Else
    .Subject = strSubject
    End If
    If strLocation & " " <> " " Then .Location = strLocation
    .ReminderSet = blReminder
    If intReminderMinutes & " " <> " " Then .ReminderMinutesBeforeStart = intReminderMinutes
    If strNotes & " " <> " " Then .Body = strNotes
    .UserProperties("AppointmentID") = lngApptID
    .Save
    .Close (olSave)
    End With

    fnAddOutlookAppt = True

    ErrExit:
    Set objOutlook = Nothing
    Set objAppt = Nothing
    On Error GoTo 0
    Exit Function

    ErrHandler:
    MsgBox "An error has occurred (fnAddOutlookAppt)" & vbCrLf & _
    "Please inform your System Administrator" & vbCrLf & vbCrLf & _
    "Error Number: " & Err.Number & " " & Err.Description, vbCritical, "Error"
    fnAddOutlookAppt = False
    Resume ErrExit


    End Function

    Thanks for your help

    Robin

Posting Permissions

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