problem interacting with Outlook from VBA (on Excel).

TATTOO DESK 0 Reputation points
2023-12-28T09:22:35.25+00:00

Hello,

From a VBA Excel macro, I use these two instructions to create a calendar in the group 'My calendars' of Outlook (theses instructions create and respectively get to an existing calendar of Outlook). They work fine on Office2016 :

To create a calendar:

Set myCalendar = namespaceOutlook.Folders(MyOutlookMail).Folders("Calendrier").Folders.Add(CalendrierName)

Or get to it if it exists:

Set myCalendar = namespaceOutlook.Folders(MyOutlookMail).Folders("Calendrier").Folders(CalendrierName)

These instructions don't work anymore on Office365. After many tries, I found out I had to use this instead:

Set TatooCalendar = namespaceOutlook.GetDefaultFolder(olFolderCalendar).Folders.Add(CalendrierName)

and

Set TatooCalendar = namespaceOutlook.GetDefaultFolder(olFolderCalendar).Folders(CalendrierName)

For what ? and is the workaround I found correct please? Thank you....

Outlook Windows Classic Outlook for Windows For business
Microsoft 365 and Office Install, redeem, activate For business Windows
Microsoft 365 and Office Excel For business Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. HansV 966 Reputation points MVP
    2023-12-29T15:37:29.4966667+00:00

    "Calendrier" is language-dependent - it should work in French-language Outlook but not in other languages.

    olFolderCalendar, on the other hand, is a symbolic constant that will work in all languages. So it's much safer to use that.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.