Skip to Content
0
Former Member
Sep 01, 2006 at 12:03 PM

Problem adding multiple BP from Excel

27 Views

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.