Adding an appointment to Outlook from Excel with VBA

bibleguy125

Board Regular
Joined
Feb 22, 2012
Messages
113
Hello,
I am trying to figure out how to add an appointment to a shared outlook calendar from Excel. I will be entering shipments in an Excel page and would love to just click a button and have an appointment made.
I am very much a novice on how programs communicate with one another. The only information that will need to go on the appointment is the subject, location, and time. We set all our appointments at 15 minutes duration. Have any ideas of how to go about this?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Okay, I got this to work, but it only adds an item to my default calendar. Is there a way to add items to another shared calendar instead of the default?
Code:
Sub Appointments()
Const olAppointmentItem As Long = 1
Dim olapp As Object
Dim OLNS As Object
Dim OLAppointment As Object
Dim ws1 As Worksheet
Dim time1 As String
Dim time2 As String


time1 = Application.InputBox(prompt:="Enter Time", Type:=1)


Set ws1 = Worksheets("Load Entry")
ws1.Range("AC1").Value = Date & time1


time2 = ws1.Range("AC1").Value


On Error Resume Next
Set olapp = GetObject(, "Outlook.Application")
If olapp Is Nothing Then Set olapp = CreateObject("Outlook.Application")
On Error GoTo 0


If Not olapp Is Nothing Then


Set OLNS = olapp.GetNamespace("MAPI")
OLNS.Logon


Set OLAppointment = olapp.CreateItem(olAppointmentItem)
OLAppointment.Subject = ws1.Range("D2").Value & " - " & ws1.Range("A2").Value & " " & ws1.Range("D5").Value
OLAppointment.Start = ws1.Range("A5").Value + TimeValue(time1 & ":00:00")
OLAppointment.Duration = 15
OLAppointment.Location = Range("G5").Value
OLAppointment.Save


'Set OLAppointment = olapp.Move(olfolder)


Set OLAppointment = Nothing
Set OLNS = Nothing
Set olapp = Nothing
End If


End Sub
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top