-2
我一個工具,將捕獲團隊成員的利用率工作。我試圖在Excel中獲得用戶的休息時間。請建議我一個vba代碼,當用戶離開LYNC時,它將在excel中啓動一個計時器,並在他/她在線時停止計時器。 這就是我將能夠獲得用戶的離開時間,其餘的將被利用。 :)如何獲得LYNC離開時用戶
我一個工具,將捕獲團隊成員的利用率工作。我試圖在Excel中獲得用戶的休息時間。請建議我一個vba代碼,當用戶離開LYNC時,它將在excel中啓動一個計時器,並在他/她在線時停止計時器。 這就是我將能夠獲得用戶的離開時間,其餘的將被利用。 :)如何獲得LYNC離開時用戶
我已經做到了.... 下面是我使用的代碼,它工作正常。 我做了一些更改以達到我的目的。
'This Macro is working fine
Public Sub macro10()
LyncContactsStatus
End Sub
Function LyncContactsStatus() As Variant
Dim appLync As CommunicatorAPI.Messenger
Dim LyncDirectory As CommunicatorAPI.IMessengerContacts
Dim LyncContact As CommunicatorAPI.IMessengerContact
Dim arrContacts() As Variant
Dim lngLoopCount As Long
Set appLync = CreateObject("Communicator.UIAutomation")
appLync.AutoSignin
Set LyncDirectory = appLync.MyContacts
ReDim arrContacts(LyncDirectory.Count - 1, 1)
For lngLoopCount = 0 To LyncDirectory.Count - 1
Set LyncContact = LyncDirectory.Item(lngLoopCount)
arrContacts(lngLoopCount, 0) = LyncContact.FriendlyName
arrContacts(lngLoopCount, 1) = LyncStatus(LyncContact.Status)
ActiveCell.Value = LyncContact.FriendlyName
ActiveCell.Offset(0, 1).Value = LyncContact.Status
If LyncContact.Status = MISTATUS_AWAY Then
If ActiveCell.Offset(0, 3).Value = "" Then
ActiveCell.Offset(0, 3).Value = Now
End If
End If
If LyncContact.Status = MISTATUS_ONLINE Then
If ActiveCell.Offset(0, 3).Value <> "" Then
ActiveCell.Offset(0, 4).Value = Now
Sheet1.Range(ActiveCell, ActiveCell.Offset(0, 4)).Select
Selection.Copy
Dim i
i = 1
Do
i = i + 1
If Sheet2.Cells(i, 1).Value = "" Then
Sheet2.Activate
Cells(i, 1).Select
'Sheet2.Activate
Sheet2.Paste
i = i + 1
Sheet1.Activate
End If
Loop Until Sheet2.Cells(i, 1).Value = ""
ActiveCell.Offset(0, 3) = ""
ActiveCell.Offset(0, 4) = ""
End If
End If
ActiveCell.Offset(1, 0).Activate
Next lngLoopCount
LyncContactsStatus = arrContacts
Set appLync = Nothing
Cells(1, 1).Activate
Application.OnTime Now + TimeValue("00:00:30"), "Macro10"
End Function
Function LyncStatus(IntStatus As Integer) As String
Select Case IntStatus
Case 1 'MISTATUS_OFFLINE
LyncStatus = "Offline"
Case 2 'MISTATUS_ONLINE
LyncStatus = "Online"
Case 6 'MISTATUS_INVISIBLE
LyncStatus = "Invisible"
Case 10 'MISTATUS_BUSY
LyncStatus = "Busy"
Case 14 'MISTATUS_BE_RIGHT_BACK
LyncStatus = "Be Right Back"
Case 18 'MISTATUS_IDLE
LyncStatus = "Idle"
Case 34 'MISTATUS_AWAY
LyncStatus = "Away"
Case 50 'MISTATUS_ON_THE_PHONE
LyncStatus = "On the Phone"
Case 66 'MISTATUS_OUT_TO_LUNCH
LyncStatus = "Out to Lunch"
Case 82 'MISTATUS_IN_A_MEETING
LyncStatus = "In a meeting"
Case 98 'MISTATUS_OUT_OF_OFFICE
LyncStatus = "Out of office"
Case 114 'MISTATUS_OUT_OF_OFFICE
LyncStatus = "Do not disturb"
Case 130 'MISTATUS_IN_A_CONFERENCE
LyncStatus = "In a conference"
Case Else
LyncStatus = "Unknown"
End Select
End Function
該代碼將記錄您的聯繫人符在表2
對於任何幫助,請寄給我的「[email protected]」
歡迎S.O!你有嘗試過什麼嗎?如果是這樣,請提供代碼。看看到[旅遊](http://stackoverflow.com/tour)和[如何提問](http://stackoverflow.com/help/how-to-ask)。友情提醒:StackOverflow不是「我們爲您代碼」的服務提供商。 [介紹VBA](https://blog.udemy.com/excel-macros-tutorial/)或[中等高級教程(http://analysistabs.com/excel-vba/codes-examples-macros-how -tos,最有用的,基礎知識,先進/)和我的[個人最喜歡的(http://analystcave.com/excel-vba-tutorial/) – Sgdva
是的,我有嘗試太多的代碼,但他們都不是爲持續時間。他們只是向我提供我的聯繫人列表中每個用戶的當前狀態。 – Rohan