AVAYA CMS Scripting through Excel VBA

shekhar_pc

Board Regular
Joined
Jan 29, 2006
Messages
185
Code:
Private Function CMSGetReport(sServerIP As String, iACD As Integer, sReportName As String, sProperty1Name As String, sProperty1Value As String, sProperty2Name As String, sProperty2Value As String, sExportName As String) As Boolean
Dim cvsApp As CVS.cvsApplication
Dim cvsConn As CVSCN.cvsConnection
Dim cvsSrv As CVSUPSRV.cvsServer
Dim Rep As CVSREP.cvsReport
Dim Info As Object, Log As Object, b As Object

Set cvsApp = New CVSUP.cvsApplication
If cvsApp.CreateServer(getusername(sServerIP), "", "", sServerIP, False, "ENU", cvsSrv, cvsConn) Then
If cvsConn.Login(getusername(sServerIP), getpassword(sServerIP), sServerIP, "ENU") Then

CMSGetReport = False

On Error Resume Next
    cvsSrv.Reports.ACD = iACD
    Set Info = cvsSrv.Reports.Reports(sReportName)
    If Info Is Nothing Then
        If cvsSrv.Interactive Then
            MsgBox "The Report " & sReportName & " was not found on ACD" & iACD & ".", vbCritical Or vbOKOnly, "CentreVu Supervisor"
        Else
            Set Log = CreateObject("CVSERR.cvslog")
            Log.AutoLogWrite "The Report " & sReportName & " was not found on ACD" & iACD & "."
            Set Log = Nothing
        End If
    Else
        b = cvsSrv.Reports.CreateReport(Info, Rep)
        If b Then
            Debug.Print Rep.SetProperty(sProperty1Name, sProperty1Value)
            Debug.Print Rep.SetProperty(sProperty2Name, sProperty2Value)
'            Debug.Print Rep.SetProperty(sProperty3Name, sProperty3Value)
            b = Rep.ExportData(sExportName, 9, 0, True, False, True)
            Rep.Quit
            CMSGetReport = True
            If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Rep.TaskID
            Set Rep = Nothing
        End If
    End If
    Set Info = Nothing
End If
End If
End Function

I got the above fuction from http://www.dbforums.com/archive/index.php/t-1003776.html. What it does is, it extracts reports from AVAYA CenterVu Supervisor 9.0 software used by call centers.

But when I used it in excel VBA, it gives me compile error "User-defined type not defined in the first line "Dim cvsApp As CVS.cvsApplication" when I try to call the function see my code below.

More info:

I searched few files on my comp in the C:\Program Files\Avaya\CentreVu Supervisor 9.0 directory and go to know that

cvsAPP is an .exe file
cvsConn is a .dll file
cvsSrv is an .exe file
CVSREP is an .exe file

Code:
Sub a()
Call CMSGetReport("172.18.3.60", 1, "Upstream Stats Rpt", "Date(s)", "03/01/06--1", "Split Numbers", "71;72;74;79;82;83", "m:\ReportsAutomation\abc.xls")
End Sub

How can I get rid of the error?

Note: The above function might not display properly due to word wrap
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try and set references to the files you listed. VBA IDE Tools > References. You can select from the list or browse. You may also try late binding though this may have a negative effect on the performance of your function. See the edited attempt below using late binding.

<table border="1" bgcolor="White"><caption ALIGN=left><font size="2" face=Courier New>Example VBA Code:</FONT></caption><tr><td><font size="2" face=Courier New>  <font color="#0000A0">Private</font> <font color="#0000A0">Function</font> CMSGetReport(sServerIP <font color="#0000A0">As</font> String, iACD <font color="#0000A0">As</font> Integer, sReportName <font color="#0000A0">As</font> String, sProperty1Name <font color="#0000A0">As</font> String, sProperty1Value <font color="#0000A0">As</font> String, sProperty2Name <font color="#0000A0">As</font> String, sProperty2Value <font color="#0000A0">As</font> String, sExportName <font color="#0000A0">As</font> String) <font color="#0000A0">As</font> <font color="#0000A0">Boolean</font>
  
     <font color="#0000A0">Dim</font> cvsApp <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
       <font color="#0000A0">Dim</font> cvsConn <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
       <font color="#0000A0">Dim</font> cvsSrv <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
       <font color="#0000A0">Dim</font> Rep <font color="#0000A0">As</font> <font color="#0000A0">Object</font>

      
       <font color="#0000A0">Dim</font> Info <font color="#0000A0">As</font> Object, Log <font color="#0000A0">As</font> Object, b <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
      
      <font color="#0000A0">Set</font> cvsApp = CreateObject("CVS.cvsApplication")
       <font color="#0000A0">Set</font> cvsConn = CreateObject("CVSCN.cvsConnection")
       <font color="#0000A0">Set</font> cvsSrv = CreateObject("CVSUPSRV.cvsServer")
       <font color="#0000A0">Set</font> Rep = CreateObject("CVSREP.cvsReport")
      <font color="#008000"> 'Set cvsApp = New CVSUP.cvsApplication</font>

      
       <font color="#0000A0">If</font> cvsApp.CreateServer(getusername(sServerIP), "", "", sServerIP, False, "ENU", cvsSrv, cvsConn) <font color="#0000A0">Then</font>
           <font color="#0000A0">If</font> cvsConn.Login(getusername(sServerIP), getpassword(sServerIP), sServerIP, "ENU") <font color="#0000A0">Then</font>
          
           CMSGetReport = False
          
           <font color="#0000A0">On</font> <font color="#0000A0">Error</font> <font color="#0000A0">Resume</font> <font color="#0000A0">Next</font>
               cvsSrv.Reports.ACD = iACD
               <font color="#0000A0">Set</font> Info = cvsSrv.Reports.Reports(sReportName)
               <font color="#0000A0">If</font> Info <font color="#0000A0">Is</font> <font color="#0000A0">Nothing</font> <font color="#0000A0">Then</font>
                   <font color="#0000A0">If</font> cvsSrv.Interactive <font color="#0000A0">Then</font>
                       MsgBox "The Report " & sReportName & " was not found on ACD" & iACD & ".", vbCritical <font color="#0000A0">Or</font> vbOKOnly, "CentreVu Supervisor"
                   <font color="#0000A0">Else</font>
                       <font color="#0000A0">Set</font> Log = CreateObject("CVSERR.cvslog")
                       Log.AutoLogWrite "The Report " & sReportName & " was not found on ACD" & iACD & "."
                       <font color="#0000A0">Set</font> Log = <font color="#0000A0">Nothing</font>
                   <font color="#0000A0">End</font> <font color="#0000A0">If</font>
               <font color="#0000A0">Else</font>
                   b = cvsSrv.Reports.CreateReport(Info, Rep)
                   <font color="#0000A0">If</font> b <font color="#0000A0">Then</font>
                       <font color="#0000A0">Debug.Print</font> Rep.SetProperty(sProperty1Name, sProperty1Value)
                       <font color="#0000A0">Debug.Print</font> Rep.SetProperty(sProperty2Name, sProperty2Value)
          <font color="#008000"> ' Debug.Print Rep.SetProperty(sProperty3Name, sProperty3Value)</font>
                       b = Rep.ExportData(sExportName, 9, 0, True, False, True)
                       Rep.Quit
                       CMSGetReport = True
                       <font color="#0000A0">If</font> <font color="#0000A0">Not</font> cvsSrv.Interactive <font color="#0000A0">Then</font> cvsSrv.ActiveTasks.Remove Rep.TaskID
                       <font color="#0000A0">Set</font> Rep = <font color="#0000A0">Nothing</font>
                   <font color="#0000A0">End</font> <font color="#0000A0">If</font>
               <font color="#0000A0">End</font> <font color="#0000A0">If</font>
               <font color="#0000A0">Set</font> Info = <font color="#0000A0">Nothing</font>
           <font color="#0000A0">End</font> <font color="#0000A0">If</font>
       <font color="#0000A0">End</font> <font color="#0000A0">If</font>
      
  <font color="#0000A0">End</font> <font color="#0000A0">Function</font>
  
</FONT></td></tr></table>
 
Upvote 0
Thank you Tom, I tried late binding and checked the following in Available References.
CVS Application Component
CVS Connection Component
CVS Server Component
CVS Report Component

Now I get an error @ getusername in the line If cvsApp.CreateServer(getusername(sServerIP), "", "", sServerIP.......

Another question why did you comment 'Set cvsApp = New CVSUP.cvsApplication?
 
Upvote 0
I don't see any code for a getusername sub or function anywhere.

Or for getpasswords.
 
Upvote 0
I know you didn't write the code.:)

Why not ask the author of the code about those functions?
 
Upvote 0
I tried becoming a member of tek-tips but it says there is an error with registration and I could not find email address of the author. Can I pass the username and password in that code?
 
Upvote 0
Because "Set cvsApp = CreateObject("CVS.cvsApplication")" line will create a new instance when you use CreateObject. You cannot use the New keyword with CreateObject for this reason. At least that's what I think. :)

getusername(sServerIP)
getpassword(sServerIP)

are both function calls that are not accounted for in your code. The original coder either had created several custom functions named "getusername" and "getpassword" or these are methods that belong to one of the above created servers (CreateObject) objects. If you know the username and password, replace these function calls with the correct two strings. I have no clue about AVAYA but am simply following some COM guidelines in trying to help you out. Your software may contain documentation for developers or the support offered on their website.
 
Upvote 0
Sure. Insert your own UN and PW by editing the assignments to the two constants.

<table border="1" bgcolor="White"><caption ALIGN=left><font size="2" face=Courier New>Example VBA Code:</FONT></caption><tr><td><font size="2" face=Courier New>  <font color="#0000A0">Private</font> <font color="#0000A0">Function</font> CMSGetReport( _
       sServerIP <font color="#0000A0">As</font> String, _
       iACD <font color="#0000A0">As</font> Integer, _
       sReportName <font color="#0000A0">As</font> String, _
       sProperty1Name <font color="#0000A0">As</font> String, _
       sProperty1Value <font color="#0000A0">As</font> String, _
       sProperty2Name <font color="#0000A0">As</font> String, _
       sProperty2Value <font color="#0000A0">As</font> String, _
       sExportName <font color="#0000A0">As</font> String) <font color="#0000A0">As</font> <font color="#0000A0">Boolean</font>
  
  <font color="#0000A0">Const</font> Username <font color="#0000A0">As</font> <font color="#0000A0">String</font> = "YourUserName"
  <font color="#0000A0">Const</font> Password <font color="#0000A0">As</font> <font color="#0000A0">String</font> = "YourPassword"
  
  <font color="#0000A0">Dim</font> cvsApp <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
  <font color="#0000A0">Dim</font> cvsConn <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
  <font color="#0000A0">Dim</font> cvsSrv <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
  <font color="#0000A0">Dim</font> Rep <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
  
  <font color="#0000A0">Dim</font> Info <font color="#0000A0">As</font> Object, Log <font color="#0000A0">As</font> Object, b <font color="#0000A0">As</font> <font color="#0000A0">Object</font>
  
  <font color="#0000A0">Set</font> cvsApp = CreateObject("CVS.cvsApplication")
  <font color="#0000A0">Set</font> cvsConn = CreateObject("CVSCN.cvsConnection")
  <font color="#0000A0">Set</font> cvsSrv = CreateObject("CVSUPSRV.cvsServer")
  <font color="#0000A0">Set</font> Rep = CreateObject("CVSREP.cvsReport")
  <font color="#008000">'Set cvsApp = New CVSUP.cvsApplication</font>
  
  <font color="#0000A0">If</font> cvsApp.CreateServer(Username, "", "", sServerIP, False, "ENU", cvsSrv, cvsConn) <font color="#0000A0">Then</font>
       <font color="#0000A0">If</font> cvsConn.Login(Username, Password, sServerIP, "ENU") <font color="#0000A0">Then</font>
      
           CMSGetReport = False
          
           <font color="#0000A0">On</font> <font color="#0000A0">Error</font> <font color="#0000A0">Resume</font> <font color="#0000A0">Next</font>
           cvsSrv.Reports.ACD = iACD
           <font color="#0000A0">Set</font> Info = cvsSrv.Reports.Reports(sReportName)
           <font color="#0000A0">If</font> Info <font color="#0000A0">Is</font> <font color="#0000A0">Nothing</font> <font color="#0000A0">Then</font>
               <font color="#0000A0">If</font> cvsSrv.Interactive <font color="#0000A0">Then</font>
               MsgBox "The Report " & sReportName & " was not found on ACD" & iACD & ".", vbCritical <font color="#0000A0">Or</font> vbOKOnly, "CentreVu Supervisor"
           <font color="#0000A0">Else</font>
               <font color="#0000A0">Set</font> Log = CreateObject("CVSERR.cvslog")
               Log.AutoLogWrite "The Report " & sReportName & " was not found on ACD" & iACD & "."
               <font color="#0000A0">Set</font> Log = <font color="#0000A0">Nothing</font>
           <font color="#0000A0">End</font> <font color="#0000A0">If</font>
       <font color="#0000A0">Else</font>
           b = cvsSrv.Reports.CreateReport(Info, Rep)
           <font color="#0000A0">If</font> b <font color="#0000A0">Then</font>
               <font color="#0000A0">Debug.Print</font> Rep.SetProperty(sProperty1Name, sProperty1Value)
               <font color="#0000A0">Debug.Print</font> Rep.SetProperty(sProperty2Name, sProperty2Value)
              <font color="#008000"> ' Debug.Print Rep.SetProperty(sProperty3Name, sProperty3Value)</font>
               b = Rep.ExportData(sExportName, 9, 0, True, False, True)
               Rep.Quit
               CMSGetReport = True
              
               <font color="#0000A0">If</font> <font color="#0000A0">Not</font> cvsSrv.Interactive <font color="#0000A0">Then</font> cvsSrv.ActiveTasks.Remove Rep.TaskID
                   <font color="#0000A0">Set</font> Rep = <font color="#0000A0">Nothing</font>
               <font color="#0000A0">End</font> <font color="#0000A0">If</font>
              
           <font color="#0000A0">End</font> <font color="#0000A0">If</font>
      
       <font color="#0000A0">Set</font> Info = <font color="#0000A0">Nothing</font>
          
       <font color="#0000A0">End</font> <font color="#0000A0">If</font>
  <font color="#0000A0">End</font> <font color="#0000A0">If</font>
         
  <font color="#0000A0">End</font> <font color="#0000A0">Function</font>
  
</FONT></td></tr></table>
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top