1

Using below code, I am able to get excel to work with CMS, but it seems that my permissons are not traveling with the code. I get an error stating "Split/Skill Cannot be modified. No write permission on 665". I do have permission to 665 (and 669) when skilling manually. Any idea what I'm doing wrong here?

 Sub Swap_Skill()Dim cvsApp As Object
 Dim cvsConn As Object
 Dim cvsSrv As Object
 Dim Rep As Object
 Dim Info As Object, Log As Object, b As Object
 Dim AcmS As String

 Set cvsApp = CreateObject("ACSUP.cvsApplication")
 Set cvsConn = CreateObject("ACSCN.cvsConnection")
 Set cvsSrv = cvsApp.Servers(1)
 Set Rep = CreateObject("ACSREP.cvsReport")
 Set cvsSrv = cvsApp.Servers(1)
 AcmS = Range("K6").Value 'variable value, currently 1217259
 On Error Resume Next
 Set AgMngObj = cvsSrv.AgentMgmt
 On Error Resume Next

 Set AgMngObj = cvsSrv.AgentMgmt
 ReDim SetArr(2, 3)
 SetArr(1, 1) = Range("L4").Value 'variable value, currently 665
 SetArr(1, 2) = 1
 SetArr(1, 3) = 0
 SetArr(2, 1) = Range("N4").Value 'variable value, currently 669
 SetArr(2, 2) = 12
 SetArr(2, 3) = 0

 AgMngObj.AcdStartUp -1, "", cvsSrv.ServerKey, -1
 AgMngObj.OleAgentSetSkill 1, "" & AcmS & "", 1, 0, 0, 0, 2, SetArr, ""

 Set AgMngObj = Nothing
 Set cvsApp = Nothing
 Set cvsConn = Nothing
 Set cvsSrv = Nothing
 End Sub 
Community
  • 1
  • 1
  • Which line is throwing the error? Is `On Error Resume Next` present when the error happens? The 2nd one is futile BTW. Or did you mean to have `On Error GoTo 0` there, to restore error handling? You create a connection object, but never do anything with it. Reference that type library and work with early-bound code if possible; you'll be able to browse the types and members available in the Object Browser (F2), and you'll get autocompletion/IntelliSense to help discover the API. Perhaps a connection might want to be `Open`ed? – Mathieu Guindon Jul 01 '17 at 04:14

1 Answers1

1

Maybe u solved this long time ago, but otherwise i'll paste you my code to skill agents:

Option Explicit
Dim cvsApp As New ACSUP.cvsApplication
Dim cvsConn As New ACSCN.cvsConnection
Dim cvsSrv As New ACSUPSRV.cvsServer
Dim Rep As New ACSREP.cvsReport
Sub SkillAgentes()


    Application.ScreenUpdating = False
    Set cvsSrv = cvsApp.Servers(1)

    Dim LastRow As Long, LastCol As Long, ws As Worksheet, wsData As Worksheet, F As Integer, C As Integer, _
    i As Integer, S As Integer, Skill As String, Prtr As Integer, SetArr() As Variant, Agentes As String, _
    Cantidad As Integer, ACD As Integer, wsA As Worksheet, wsS As Worksheet, AgMngObj As Object

    Set wsData = ThisWorkbook.Sheets("Trasvases")
    Set ws = ThisWorkbook.Sheets("Cambios Skill")
    Set wsA = ThisWorkbook.Sheets("Agentes")
    Set wsS = ThisWorkbook.Sheets("Skills")
    Set AgMngObj = cvsSrv.AgentMgmt

    S = 1
    LastRow = ws.Range("F" & ws.Rows.Count).End(xlUp).Row
    For i = 2 To LastRow
        LastCol = ws.Cells(i, 8).End(xlToRight).Column
        Agentes = ws.Cells(i, ws.Cells.Find("login").Column)
        Cantidad = ws.Cells(i, 3)
        If ws.Cells(i, 2) = "SUR" Then ACD = 1
        If ws.Cells(i, 2) = "NORTE" Then ACD = 2
        ReDim SetArr(Cantidad, 4)
        For C = 8 To LastCol Step 2
            On Error Resume Next
            Skill = ws.Cells(i, C).Value
            Prtr = ws.Cells(i, C + 1).Value
            SetArr(S, 1) = Skill
            SetArr(S, 2) = Prtr
            SetArr(S, 3) = 0
            SetArr(S, 4) = 0
            S = S + 1
        Next C
        AgMngObj.AcdStartUp -1, "", cvsSrv.ServerKey, -1
        AgMngObj.OleAgentSetSkill_R16_1 ACD, Agentes, Prtr, 0, 0, 0, Cantidad, SetArr, ""
        Dim Tiempo As String: Tiempo = Format(Now, "hh:mm:ss")
        ws.Cells(i, 50).Value = Tiempo


        LastRow = wsData.Range("A1000").End(xlUp).Row
        Dim x As Integer
        For x = 1 To LastRow
            If wsData.Cells(x, 5) = wsA.Cells.Find(Agentes).Offset(0, 1) Then
                If wsData.Cells(x, 7) = 0 Then
                    wsData.Cells(x, 7).Value = Tiempo
                    GoTo Cambiado
                End If
            End If
        Next
        F = wsData.Range("A1000").End(xlUp).Row + 1
        wsData.Cells(F, 1).Value = Format(Date, "dd/mm/yyyy")
        If Format(Date, "dd") < 13 Then wsData.Cells(F, 1).Value = Format(Date, "mm/dd/yyyy")
        wsData.Cells(F, 2).Value = ws.Cells(19, 1)
        wsData.Cells(F, 3).Value = ws.Cells(21, 1)
        wsData.Cells(F, 4).Value = wsA.Cells.Find(Agentes, LookAt:=xlWhole).Offset(0, 2).Value
        wsData.Cells(F, 5).Value = wsA.Cells.Find(Agentes, LookAt:=xlWhole).Offset(0, 1)
        wsData.Cells(F, 6).Value = Tiempo
        wsData.Cells(F, 8).FormulaR1C1 = "=IF(RC[-1]="""","""",RC[-1]-RC[-2])"
        wsData.Cells(F, 9).FormulaR1C1 = ws.Cells(i, ws.Cells.Find("Modo Origen").Column)
        wsData.Cells(F, 10).Value = _
            wsS.Cells(wsS.Cells.Find(ws.Cells(i, ws.Cells.Find("Modo a conectar:").Column)).Row, _
            wsS.Cells.Find("Destino").Column)
        wsData.Cells(F, 11).Value = ws.Cells(i, ws.Cells.Find("Motivo Trasvase").Column).Value
Cambiado:
        S = 1
    Next i

It does indeed have too much code, but i belive you can get what you need. With this code you may change at once as many agents skills as you want. This is how the table where you input the logins and skills should be. Notice that you must enter at least the ACD, quantity of skills that you are going to put in, login, skills and their priority.

What the table looks like

Most of the stuff is to record where the agent comes from, goes to and the time is spending on that change.

Hope it helps and sorry for my english.

Damian
  • 5,152
  • 1
  • 10
  • 21