I am trying to connect Lotus Notes with Sage Payroll, the main problem is that I cannot use a COM object like this:
Public oPayrollSDO As New PAYSDOLib.Connection
I have to use the CreateObject method which is fine, but when I try to pass Company Object as a parameter, it’s not accepted (notes throws an error) since oCompany is a variant in Notes and the method expects oCompany object:
oPayrollSDO.GetCompany oCompany
In order to get around this problem, I created a VB6 ActiveX DLL with the following code, but ran into problems:
Public oPayrollSDO As New PAYSDOLib.Connection
Public oCompany As PAYSDOLib.Company
Public oPayment As New PAYSDOLib.Payment
Public oLastError As New PAYSDOLib.LastError
Public Sub ConnectToPayroll(strPath As String)
’ Error Handler
On Error GoTo ErrorHandler
oPayrollSDO.ConnectToDatabase strPath, “MANAGER”, “”
Exit Sub
’ Error Handling Code
ErrorHandler:
MsgBox ("Payroll SDO has generated the following error: " & oLastError.Value & " " & oLastError.Text)
End Sub
Public Sub DisconnectFromPayroll()
Call oPayrollSDO.Disconnect
Set oPayrollSDO = Nothing
Set oCompany = Nothing
Set oPayment = Nothing
Set oLastError = Nothing
End Sub
Public Sub CreatePayment()
' Get Company from Connection Object
oPayrollSDO.GetCompany oCompany
' Get Payments Collection
oCompany.GetPayment oPayment
End Sub
Here’s how I call it from Lotus Notes:
Sub Click(Source As Button)
Dim oGeneric
Set oGeneric = CreateObject("PayrollSDK.Generic")
Call oGeneric.ConnectToPayroll("C:\ProgramData\Sage\Payroll\COMPANY_001\PAYDATA\Payroll.mdb")
oGeneric.CreatePayment
oGeneric.oPayment.MoveToReference 1
Msgbox oGeneric.oPayment.Reference + " - " + oGeneric.oPayment.Description
oGeneric.oPayment.MoveNext
Msgbox oGeneric.oPayment.Reference + " - " + oGeneric.oPayment.Description
oGeneric.DisconnectFromPayroll
Set oGeneric = Nothing
End Sub
It works, but unfortunately at the end once the code has finished executing Lotus Notes crashes. Any insight into this would be greatly appreciated.