I'm using some slightly amended VBA code provided by Sage to connect to Sage 50 Accounts - this works on some machines, but not with others, despite them all having the same version of Sage (25.1.128), and has previously worked on all machines without issue. The error specifically occurs when attempting to instantiate the Sage Data Object, where i get 'Run-time error ' 429': ActiveX component can't create object'.
I've tried reinstalling Sage on one of the problem machines and checked the correct references are added to the VBA project. All machines in question are running windows 10 64 bit. This is the connection code I'm using:
Sub SageConnectTest()
Dim oSDO As SageDataObject250.SDOEngine
Dim oWS As SageDataObject250.WorkSpace
Dim oSdc As Object, oSrs As Object
Dim szDataPath As String
Set oSDO = New SageDataObject250.SDOEngine
Set oWS = oSDO.Workspaces.Add("Example")
szDataPath = oSDO.SelectCompany("C:\ProgramData\Sage\Accounts\2019")
If szDataPath <> "" Then
' Try to Connect - Will Throw an Exception if it Fails
If oWS.Connect(szDataPath, XXXX, XXXX, XXXX) Then
MsgBox "Connection to Sage is Successful!", vbOKOnly + vbInformation, "Sage Connection Test"
End If
End If
If oSDO.isregistered = True Then
MsgBox "Sage Data Object is Registered", vbOKOnly + vbInformation, "Sage Connection Test"
Else
MsgBox "SDO registration Faliure", vbOKOnly + vbCritical, "Sage Connection Test"
End If
oWS.Disconnect
Exit Sub
Errhandle:
oWS.Disconnect
MsgBox "There was an error connecting to Sage - disconnecting", vbOKOnly + vbCritical, "Sage Connection Test"
End Sub
Googling the problem found a few results that point to a tlb file called 'SdoENG250.tlb' - I've verified that the file is located on the problem machines, but I believe it may need to be registered and I'm not sure how to do that, or even check to see if it is registered. I'm don't even know if that's the source of the problem at this point.