View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
NewBike NewBike is offline
external usenet poster
 
Posts: 15
Default Creating Outlook Appointment

Hi Steve -
Thanks for the response!!

Two questions though:
Can you explain what you are doing with the X and R commands and I see you
are setting the Mapi folder, to the default one, but how can I set it to a
Public folder? The folder I actually want the appointments in is like a 3rd
level Public folder (Public\Division1\Shipping Calendar).


"Steve Yandl" wrote:

Here is an example of a sub that makes a set of appointments where start
times are in column A and location in Column B. I set a reference to the
Microsoft Outlook object library from 'Tools References'

Sub ScheduleAppts()
Dim ol As New Outlook.Application
Dim ns As Outlook.Namespace
Dim olFolder As Outlook.MAPIFolder
Dim appt As Outlook.AppointmentItem
Dim R As Integer
Dim X As Integer

R = Range("A65536").End(xlUp).Row

Set ns = ol.GetNamespace("MAPI")
Set olFolder = ns.GetDefaultFolder(olFolderCalendar)

For X = 1 To R
Set appt = olFolder.Items.Add
With appt
.Start = Sheets("Sheet1").Cells(X, 1).Value
.Location = Sheets("Sheet1").Cells(X, 2).Value
.Save
End With
Next X

Set ol = Nothing
Set ns = Nothing
Set appt = Nothing
End Sub


Steve
"NewBike" wrote in message
...
Hi again -
I am trying to write a macro that when a button is clicked on a
spreadsheet,
it will use the data entered on the new row to create an appointment in
Outlook...

The area that I am experiencing difficulty in is the appointment time,
duration and body text.

Here is my code:
Sub SetAppt()

Dim olApp As Outlook.Application
Dim Appt As Outlook.AppointmentItem

Set olApp = CreateObject("Outlook.Application")
Set Appt = olApp.CreateItem(olAppointmentItem)

With Appt
.Start = Range("L7").Value
.End = Range("L7").Value
.Subject = Range("I7").Value & Range("a7").Value &
Range("d7").Value
.Body = Range("e7").Value
.ReminderSet = False
End With
Set Appt = Nothing
Set olApp = Nothing

End Sub

Any help is appreciated.