【Excel VBA】Outlookにログインしているユーザーの部署や役職を取得する方法

【Excel VBA】Outlookにログインしているユーザーの部署や役職を取得する方法

Excel VBAでOutlookでログインしているユーザーのOffice365の部署や役職名を取得するコードを紹介します。

実際のコード

Excel VBA
Sub department() Dim OL, olAllUsers, oExchUser, oentry, myitem As Object Dim User As String Set OL = CreateObject("outlook.application") Set olAllUsers = OL.Session.AddressLists.Item("All Users").AddressEntries User = OL.Session.CurrentUser.Name Set oentry = olAllUsers.Item(User) Set oExchUser = oentry.GetExchangeUser()
  '部署名 MsgBox oExchUser.Department
  '役職名
  MsgBox oExchUser.JobTitle
End Sub

取得元

役職や部署の取得元は、https://entra.microsoft.com/のユーザーやhttps://portal.azure.com/のAzure Active Directoryのユーザーなどで確認できる役職や部署名です。

参考

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA