Place Outlook appointment in a different user's calendar

Human_doing

Board Regular
Joined
Feb 16, 2011
Messages
137
Hi all,

The below code puts an appointment in my Outlook calendar, could anyone please tell me how to place an appoint in another user's calendar? For example if the other user's username was ObamaB?

Many thanks in advance for your help,

Code:
Private Sub CommandButton1_Click()
 
Dim olApp As Outlook.Application
Dim olApt As AppointmentItem
 
Set olApp = New Outlook.Application
Set olApt = olApp.CreateItem(olAppointmentItem)
With olApt
 
    .Start = Date + 1 + TimeValue("19:00:00")
    .End = .Start + TimeValue("00:30:00")
    .Subject = "Piano Lesson"
    .Location = "The Teacher's House"
    .Body = "Don't forget to take an apple for the teacher"
    .BusyStatus = olBusy
    .ReminderMinutesBeforeStart = 120
    .ReminderSet = True
    .Save
 
    End With
 
    Set olApt = Nothing
    Set olApp = Nothing
 
    MsgBox "Success!!!"
 
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
You can put a meeting into someone else's Calendar, not an appointment.

If you want to turn the appointment into a meeting and invite someone, you need to:

1) add recipients, i.e.

Rich (BB code):
With olApt
  .Recipients.Add johnny_b_goode@maybelline.com
  ' rest of your code

2) Tell Outlook that it's a meeting, i.e.

Rich (BB code):
.MeetingStatus = olMeeting

3) Call the .Send Method, i.e.

Rich (BB code):
.Save
.Send
End With
 
Upvote 0
Hi,
I'm trying to do something similar and need some help.

I want to create several calendars, one for each person I manage, and then share it with them so that they see their tasks and get reminders. To do that, I use this code:

Code:
Set olNamespace = olApp.GetNamespace("MAPI")
Set olAptAdd = olNamespace.GetDefaultFolder(olFolderCalendar)
Set olAptAdd = olAptAdd.Folders(CalendarName)
With olAptAdd.Items.Add(1)

The problem is that I get the reminders but they do not. So, instead I thought maybe they could create the folder and share it with me and then I can add appointments to it and they will get the reminders and I won't, which I am ok with. I use the code you referenced and I'm trying to go to not their default Calendar folder but to one subfolder called "JW1":

Code:
Set olAptAdd = olNamespace.GetSharedDefaultFolder(olRecip, olFolderCalendar)
Set JeremysFolder = olAptAdd.Folders("JW1")
With olAptAdd.Items.Add

However, it looks like .Folders is not supported with the GetSharedDefaultFolder method like it is iwth GetDefaultFolder. Any ideas? Thanks!
 
Upvote 0
GetSharedDefaultFolder returns either a Folder or MAPIFolder Object, depending on your Outlook version. Those objects each have their own Folders collection. Can you post more of your code?
 
Upvote 0
Thanks for responding, here it is:

Code:
Public Sub Update_Appointment(subject As String, dueDateTime As Date, CalendarName As String, body As String, CategoryNumber As Integer, TaskCompleted As Boolean)
Dim olApt As Outlook.AppointmentItem 'object
Dim olAptAdd As Object
Dim JeremysFolder As Outlook.MAPIFolder 'had this as Object
Dim olRecip As Outlook.Recipient
 
If olApp Is Nothing Then
Set olApp = New Outlook.Application
Set olNamespace = olApp.GetNamespace("MAPI")
Set olRecip = olNamespace.CreateRecipient("Jeremy")
Set olCalendarFolder = olNamespace.GetSharedDefaultFolder(olRecip, olFolderCalendar)
End If
 
Set olAptAdd = olNamespace.GetSharedDefaultFolder(olRecip, olFolderCalendar)
olAptAdd.Display
Set JeremysFolder = olAptAdd.Folders("JW1") 'erring out here
With JeremysFolder.Items.Add
.Start = dueDateTime
.AllDayEvent = True
.subject = subject
.body = body
If CalendarName = "MASTER SCHEDULE" Then
.ReminderSet = False
Else
.ReminderSet = True
.ReminderMinutesBeforeStart = 1440
End If
.Categories = CategoryNumber
.Close olSave
 
End With
 
 
End Sub

msdn doesn't show the folders collection with GetSharedDefaultFolder, only GetDefaultFolder - does that mean it's not supported?
 
Upvote 0
I Googled 'GetSharedDefaultFolder' and the first three hits were for MSDN:

Office 2010:
http://msdn.microsoft.com/en-us/lib...utlook._namespace.getshareddefaultfolder.aspx

Office 2003:
http://msdn.microsoft.com/en-us/library/aa220116(v=office.11).aspx

Office XP:
http://msdn.microsoft.com/en-us/library/aa158295(v=office.10).aspx

They all mention that the method returns a Folder or MAPIFolder Object, depending on your version (I assume pre-2007 as your code uses MAPIFolder). Note that you need delegate access to that user's Calendar.

If you have delegate access to that user's Calendar, and the sub-folder you are trying to access, and it still won't work, it's possible that GetSharedDefaultFolder only provides access to the default folders, and you won't be able to access any other folders.
 
Last edited:
Upvote 0
I'm actually using 2010 but noticed the MAPIfolder issue you mentioned and removed it.

I had the user right click his "Calendar" in outlook and click share and then share it with me and I was able to add appointments to it since it's the default but when I try to go to the subfolder I have issues.

I noticed you posted about shared calendar reminders as well. If I can't get this to work, is there anything new where reminders from a calendar that someone else shared will pop up on a user's machine - without an add-in?

I don't see how Microsoft thought no one would use that - at least give us the option to select yes or no for shared reminders.
 
Upvote 0
Is there any reason why the appointment has to be in a subfolder, not the default?

If you add an appointment to a user's default (shared) calendar, the reminder should appear on their machine. Have you tried it?
 
Upvote 0

Forum statistics

Threads
1,226,217
Messages
6,189,687
Members
453,563
Latest member
Aswathimsanil

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