Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Creating appts in code (Outlook98/WinNT4)

    I recently 'discovered' how to send emails through code by creating a mailto: url containing the required info (to, subject, etc).

    Could anyone tell me if there is a similar way to create an appointment via code?

    Ta muchly!
    Beryl M


  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating appts in code (Outlook98/WinNT4)

    For appointments, it is not as simple as that. This is because mailto: create an e-mail in whatever mail system you are using, it is not specific to Outlook. An appointment, however, is not so general. You need to use Automation to control Outlook 98 in code:

    Sub MakeAppointmentTest()
    Dim oOLApp As Outlook.Application
    Dim oAppt As AppointmentItem
    ' Create an instance of Outlook
    Set oOLApp = CreateObject("Outlook.Application")
    ' Create an appointment
    Set oAppt = CreateItem(olAppointmentItem)
    With oAppt
    .BusyStatus = olBusy
    .Subject = "Strategy Meeting"
    .Location = "Conference Room B"
    .Start = #7/15/2003 1:30:00 PM# ' must be in US date/time format
    .Duration = 90 ' in minutes
    .Save ' or .Display if you want to edit the appointment immediately
    End With
    ' Clean up
    Set oAppt = Nothing
    oOLApp.Quit
    Set oOLApp = Nothing
    End Sub

    For this to work, you must set a reference to the Microsoft Outlook 98 Object Library (or something like that) in Tools | References... in the Visual Basic Editor of the program you're using to automate Outlook.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Creating appts in code (Outlook98/WinNT4)

    Hi Hans, thanks for that. Just one quick question - is that in Outlook VBA or one of the others? Only I haven't actually got to grips with Outlook's code yet ...

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>
    Beryl M


  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating appts in code (Outlook98/WinNT4)

    Hi Beryl,

    If I remember correctly, you can't program Outlook 98 directly that way you can program in Word or Excel; VBA was used there only to program forms. In later versions of Outlook, you can create program code much like you do in Word or Excel.

    Instead, you must call the code I posted from another application (VB6, Word, Excel, ...). That's why I added that you must set a reference to the Outlook 98 Object Model.

    You can download an Automation help file from OFF97: Microsoft Office 97 Automation Help File Available.

  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Creating appts in code (Outlook98/WinNT4)

    Thanks, Hans, I'll look into that - I did notice your added comment, but not until after I had replied!

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    Beryl M


  6. #6
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Creating appts in code (Outlook98/WinNT4)

    Hi Hans, I've just been experimenting with the code you posted and I having a couple of problems (not, I think, your fault - in fact, I'm probably just being very stupid - if so, I apologise now!):
    <UL><LI>Having copied the code across, I debugged it and it keeps saying 'sub or function not defined' for 'CreateItem' (ie Set oAppt = CreateItem(olAppointmentItem)?
    <LI>When I tried to call up the help on AppointmentItem it told me the Outlook help needed to be installed, so I followed its precise directions to install it, which went fine, then tried again - and got exactly the same message! How do I get it to see that the help file is there?![/list]<img src=/S/sigh.gif border=0 alt=sigh width=15 height=15> The fact that it's Friday doesn't seem to be helping yet!

    Thanks for your help
    Beryl M


  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Creating appts in code (Outlook98/WinNT4)

    1. Try

    Set oAppt = oOLApp.CreateItem(olAppointmentItem)

    instead of

    Set oAppt = CreateItem(olAppointmentItem)

    The "oOLApp." in front of CreateItem specifies that CreateItem is a method of the Outlook Application object.

    2. I've never had to install the help for Outlook 98 VBA myself, so I can't help with that. Were the instructions the same as those in OL98: How to Install Visual Basic Help?

Posting Permissions

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