Skip to Content
author's profile photo Former Member
Former Member

Connecting to the DI from MS Excel

This code snippet works fine from vb.net, however, I can't get a connection from Excel. I added a reference to SAPbobsCOM. Everything is fine up until I call .connect.

-


Sub MyMacro()

Dim vCompany As SAPbobsCOM.Company

Set vCompany = New SAPbobsCOM.Company

'set parameters for connection

vCompany.CompanyDB = "MyCompany"

vCompany.Password = "MyPassword"

vCompany.UserName = "MyUsername"

vCompany.Server = "MyServer"

vCompany.UseTrusted = False

vCompany.DbUserName = "MyDBUsername"

vCompany.DbPassword = "MyDBPassword"

vCompany.Connect

If vCompany.Connect <> 0 Then

MsgBox "Failed to connect"

Exit Sub

End If

End Sub

-


Any ideas?

TIA

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 25, 2005 at 08:52 AM

    Hello TIA

    From the check that i have done,

    i think that you are connected to the company but you check in the condition is wrong

    it should be:

    If vCompany.<b>Connected</b> = False Then
    MsgBox "Failed to connect"
    Exit Sub
    End If

    Regards, Avi

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Maria Trinidad MARTINEZ GEA

      Trinidad:

      Can you tell I am new to the API? 😉

      I am working with the 30 day demo while we wait for our "real software" to arrive. So, the docs I am using are limited.

      I was indeed confusing .connect and .connected

      Thanks for your help!

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.