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

Problem adding multiple BP from Excel

Hi all,

I am trying to add multiples BP from a excel table.

I read the data from excel correctly, then i have added the first BP well but then, the next BP cant added because always try to insert the fist BP. But the dates that i recover is the second, third, fourth....

the code is:

excel = CreateObject("Excel.Application") 'Create Excel Object.

excel.Workbooks.Open("D:Documents and SettingsAdministratorDesktopClientes.txt", , , 6, , , , , ";", , , , , , ) 'Excel imports well

i = 2

While excel.Cells(i, 1).Text <> ""

bp.CardCode = "C" & excel.Cells(i, 3).Text

aplicacion.MessageBox(i & excel.Cells(i, 3).Text & bp.CardCode)

bp.CardName = excel.Cells(i, 4).Text

bp.AdditionalID = excel.Cells(i, 6).Text

bp.Addresses.AddressName = "direccion 1"

bp.Addresses.Street = excel.Cells(i, 7).Text

bp.Addresses.Add()

bp.Phone1 = excel.Cells(i, 16).Text

codigoError = bp.Add()

If codigoError <> 0 Then

Call compañia.GetLastError(codigoError, menserror)

If (0 <> codigoError) Then

MsgBox("Found error:" + Str(codigoError) + "," + menserror)

End If

aplicacion.MessageBox("no se ha introducido")

End If

GC.Collect()

i = i + 1

End While

The code error is number -1 becouse allways is the same BP....

How can i inicialize the BP object... or what must i do??

King regards,

Alfredo Temprano.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 05, 2006 at 10:18 AM

    Can i add multiple Business Partners without inizialize the object?

    Regards,

    Alfredo Temprano

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi alfredo!

      I would recommend you to create a new diapi bp object at a time, and free it.

      pseudoCode:

      while (readFromExcel)

      dim oBP as BusinnesPartner

      oBP = company.createobject(.....)

      with oBP

      oBp.code = ...

      obp.name = ...

      end with

      obp.add

      releaseobject( BP )

      read next from excel...

      end while

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.