excel - 获取已登录的 Office 365 用户 ID
问题描述
如何在 Excel VBA 中获取已登录的 Office 365 用户 ID?
不是Application.Username
或Environ("username")
解决方案
我假设“ID”是指这个人的名字?以下应该工作
Sub getLoggedInUser()
Dim olApp As Object
Dim olNS As Object
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
With olNS.session.currentuser.AddressEntry.GetExchangeUser
'some different options for getting the name
Debug.Print .Name
Debug.Print .FirstName
Debug.Print .LastName
Debug.Print .Alias
End With
End Sub
推荐阅读
- java - Spring security UsernamePasswordAuthenticationToken 始终返回 403:用户凭据已过期
- linux - 安装登录屏幕主题时 SDDM 崩溃
- java - 用于转换 Java 对象字段的设计模式
- delphi - 为什么我的 .dfm 文件中存储了 Text = ''?默认情况下,不应存储空字符串
- python - Dask 连接高内存使用
- c# - Blazor webassembly access-control-allow-origin 错误和 Google API
- javascript - 如何区分 Microsoft 文件类型和 base64 字符串?
- digital-ocean - 获取 GOOGLE_APPLICATION_CREDENTIALS 以在 Digital Ocean 中工作
- nginx - Nginx 重写 - 从 URL 中删除静态资产的路径段?
- amazon-dynamodb - 如何将主键传递给 DynamoDB 中的 put_item 以获取嵌套 JSON