如何在Excel VBA中取得同事的Lync在线状态?

gwxkai 2014-10-08 03:06:24
公司部署的是Excel 2013及Lync 2013 (Lync即Office Communicator), 有没有什么办法在Excel VBA中访问Lync的对象,取得同事的在线状态?

在网上能搜到的就是下面的代码片段,不过电脑上没看到CommunicatorAPI,可能Lync不支持吧,其他一些方法都要.net已经Visual Studio,很想知道能不能就用VBA解决这个需求?有经验的分享一下,谢谢。

Public Sub User_Status_OCS()
Dim myOCS As New CommunicatorAPI.Messenger 'Office Communicator API
Dim OCS_User_Mail_ID As String
Dim curr_status As Integer
Dim flag As Integer
Dim stat As String

stat = ""
OCS_User_Mail_ID = "User@mail.com" 'Change the Mail ID to USER Mail.
curr_status = myOCS.GetContact(OCS_User_Mail_ID, myOCS.MyServiceId).Status
If curr_status = 34 Then stat = "Away"
If curr_status = 10 Then stat = "Busy"
If curr_status = 18 Then stat = "Idle"
If curr_status = 1 Then stat = "Offline"
If curr_status = 2 Then stat = "Online"
If curr_status = 0 Then stat = "Unknown"

MsgBox "User:" & OCS_User_Mail_ID & " OCS Status = " & stat
End Sub
...全文
1234 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dsd999 2014-10-09
  • 打赏
  • 举报
回复
代码试过没问题,关键是在vba里添加reference Microsoft Office Communicator2007....

5,139

社区成员

发帖
与我相关
我的任务
社区描述
其他开发语言 Office开发/ VBA
社区管理员
  • Office开发/ VBA社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧