Getting Excel to update Outlook Calendar

  • Thread starter Thread starter Marcus
  • Start date Start date
M

Marcus

This could be a challenge.

I want to get a excel userform to update my Calendar in MS
Outlook.

The aim is to insert dates and times into userform textboxs
and then when I submit this information to a spreadsheet
it automatically insert "busy" into the users calendar.

Is this possible......
 
Sub test()
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objAppointment As Outlook.AppointmentItem

On Error Resume Next
Set objApp = GetObject(, "Outlook.Application")
If Err.Number Then Set objApp = CreateObject("Outlook.Application")
On Error GoTo 0

If Not objApp Is Nothing Then
Set objNS = objApp.GetNamespace("MAPI")
objNS.Logon

Set objAppointment = objApp.CreateItem(olAppointmentItem)
objAppointment.Subject = Range("A1").Value
objAppointment.Start = Range("B1").Value
objAppointment.Duration = Range("C1").Value
objAppointment.Save

Set objAppointment = Nothing
Set objApp = Nothing
End If

End Sub


Add a reference to Microsoft Outlook #.0 Object Library

Suggest you play with the objAppointment properties to fill in the other
details you're after

To late bind (no need for references), use:
Dim objApp As Object
Dim objNS As Object
Dim objAppointment As Object
 
Many thanks.....

Marcus
-----Original Message-----
Sub test()
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objAppointment As Outlook.AppointmentItem

On Error Resume Next
Set objApp = GetObject(, "Outlook.Application")
If Err.Number Then Set objApp = CreateObject ("Outlook.Application")
On Error GoTo 0

If Not objApp Is Nothing Then
Set objNS = objApp.GetNamespace("MAPI")
objNS.Logon

Set objAppointment = objApp.CreateItem (olAppointmentItem)
objAppointment.Subject = Range("A1").Value
objAppointment.Start = Range("B1").Value
objAppointment.Duration = Range("C1").Value
objAppointment.Save

Set objAppointment = Nothing
Set objApp = Nothing
End If

End Sub


Add a reference to Microsoft Outlook #.0 Object Library

Suggest you play with the objAppointment properties to fill in the other
details you're after

To late bind (no need for references), use:
Dim objApp As Object
Dim objNS As Object
Dim objAppointment As Object


--
Rob van Gelder - http://www.vangelder.co.nz/excel





.
 
I don't have Outlook on my home pc, but if the OP is using latebinding, then
olAppointmentItem
will need to be defined or replaced with a number.

(Any idea what value?)
 
By any chance doy ou know of any code which would allow me
to update a number of calendar at the sam time if the
person email address was known.

Marcus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top