Skip to Content

Excel cannot connect to Server

Aug 31, 2017 at 12:14 PM


avatar image

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:

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)
            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?



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Aug 31, 2017 at 01:11 PM

Hi Leon,

Check the following:

1. Try to insert LicenseServer or SLDServer property in DI API code and check the connection again.

2. Check whether the same VB code can be used in Visual Studio to make the company connection?

Let us know the results!

Kind regards,


SAP SME Support

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi, Ankit

Thanks for your response.

I found my error.

I used the wrong DI API Reference:

SAP Business One DI API version 7 instead of SAP Business One DI API version 9.0.

Now, I can connect successfully. I must now test if the rest of the code works.


But I have a related problem. Can you help?

I use windows 7 on 32-bit installation.

My colleague has windows 10 on 64-bit installation.

What works for me does not work on the 64-bit installation. Any idea?

Best Regards,



Hi, Ankit

I am glad to inform you that I have successfully adapted the model Excel VBA to my needs.

It took me less than 1 day to do this, and it works wonders.

If I had developed an SDK add-on, it would have taken me much more time.

Thanks for all your help.



Hi Leon,

Check the MS Excel is 64-Bit or 32- Bit?

If 64-Bit, probably you need to refer to 64-Bit DI API reference. Otherwise, tell us what is the error that you are having?

Kind regards,


SAP SME Support