Pass values from a sheet of excel to a ActiveX control
Hello,
I have a ActiveX control that is a table, and i want to pass the values in the excel sheets to the table of the activeX but the code don't work. Can anybody give me a idea?
Here is the code:
Private Sub DOWNLOAD_Click()
On Error Resume Next
' The required BAPI
Set objTable = Nothing
Set objTeste = objBAPIControl.Add("ZPD_TESTE_EXCEL")
If objTeste.Call Then
Set objTable = objTeste.Tables("T_INTER")
For i = 1 To objTable.RowCount
ActiveSheet.Cells(8 + i, 1) = objTable.Cell(i, 1)
ActiveSheet.Cells(8 + i, 2) = objTable.Cell(i, 2)
ActiveSheet.Cells(8 + i, 3) = objTable.Cell(i, 3)
Next i
Else
MsgBox "Erro a chamar a função."
End If
' objTable.AppendGridData
End Sub
Thanks,
Ricardo
Re: Pass values from a sheet of excel to a ActiveX control
I do it differently - I open the spreadsheet as an ADO database (see http://www.connectionstrings.com/), then do a Select statement to get the data. Then it's easy to assign the data to a control.
Re: Pass values from a sheet of excel to a ActiveX control
Is it me, or are the lines like this..
VB Code:
ActiveSheet.Cells(8 + i, 1) = objTable.Cell(i, 1)
..the wrong way around (you are currently putting the value into Excel). ;)