vba that creates appointment in shared calendar

aspiringnerd

New Member
Joined
Apr 22, 2022
Messages
39
Office Version
  1. 365
Platform
  1. Windows
I'm hoping that it's just as simple as replacing the 3rd line with a different namespace paramater, perhaps namespace.getshareddefaultfolder? I just don't know how to make it work, I'm struggling with the syntax on the ms website.

I added a comment in the code where I'm pretty sure I need to replace it with but I'm stuck, documentation isn't super clear on my specific need.

VBA Code:
Sub new_event()
    Set olOutlook = CreateObject("Outlook.Application")
    Set Namespace = olOutlook.GetNameSpace("MAPI")
    Set oloFolder = Namespace.GetDefaultFolder(9) 'this writes to my calendar, but I'd like to write it to a default calendar shared by someone else to me
    
    
    Set Appointment = oloFolder.items.Add
    
    With Appointment
        .AllDayEvent = True
        .Start = Cells(ActiveCell.Row, "T").Value
        .End = Cells(ActiveCell.Row, "U").Value
        .Categories = Cells(ActiveCell.Row, "V").Value
        .Subject = Cells(ActiveCell.Row, "W").Value
        .Display
        
    End With
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Namespace.GetSharedDefaultFolder(9) ?

GetSharedDefaultFolder( _Recipient_ , _FolderType_ )

The syntax has two arguments, 9 is definitely the folder type but for recipient, I tried using the email address but I get a mismatched error.


from above: "The owner of the folder. Note that the Recipient object must be resolved."

for recipient, not sure on the correct syntax or how to 'resolve' the recipient object
 
Upvote 0
Did you look at the code example there, which resolves the recipient?
Afraid I've never done this, so probably am not helping too much,
 
Upvote 0
GetSharedDefaultFolder( _Recipient_ , _FolderType_ )

The syntax has two arguments, 9 is definitely the folder type but for recipient, I tried using the email address but I get a mismatched error.


from above: "The owner of the folder. Note that the Recipient object must be resolved."

for recipient, not sure on the correct syntax or how to 'resolve' the recipient object

Did you look at the code example there, which resolves the recipient?
Afraid I've never done this, so probably am not helping too much,
I did solve it, your comment helped me think about it in a different way so I appreciate it. The solution is as follows:
VBA Code:
    Set myRecipient = Namespace.CreateRecipient("recipient@outlook.com")
    Set oloFolder = Namespace.GetSharedDefaultFolder(myRecipient, 9)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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