Skip to Content
0
Aug 31, 2017 at 12:14 PM

Excel cannot connect to Server

221 Views

Hi, Everybody

I have several thousand Journal Entries to post in SAP B1.

This is a one time job, so I don't want to spend too much time developing a complete add-on.

I got a quick and nice solution on the web:

e-tanit.blogspot.com/

http://e-tanit.blogspot.com/2012/07/journal-entries-in-sap-business-one.html?m=1

Journal entries in SAP Business one with Excel

The trick is to put the Journal Entries in 2 Excel worksheets: one for header, one for rows, and to use VBA and DI API to post the Journal Entries.

But I could not connect to the server. Here is my code in the VBA module:

Public Sub login()
    
    Set oCompany = New SAPbobsCOM.Company  'initialate DI company object
    oCompany.DbServerType = dst_MSSQL2008
    oCompany.Server = "KLSAP"
    oCompany.DbUserName = "sa"
    oCompany.DbPassword = "78910"
    oCompany.CompanyDB = "ABCDLTD"
    oCompany.UserName = "Manager"
    oCompany.Password = "ABCD"
      
     lRetCode = oCompany.Connect
     If lRetCode <> 0 Then
            sErrMsg = oCompany.GetLastErrorDescription
            MsgBox (sErrMsg)
      Else
            MsgBox ("Connected to: " & oCompany.CompanyName)
        End If
End Sub

It gives the following error message:

"Failed to connect to SBO Common"

Can anybody tell me what's wrong with the code?

Is there any connection detail I missed?

Thanks

Leon