Results 1 to 3 of 3

Thread: Pass values from a sheet of excel to a ActiveX control

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    13

    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

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Pass values from a sheet of excel to a ActiveX control

    Is it me, or are the lines like this..
    VB Code:
    1. ActiveSheet.Cells(8 + i, 1) = objTable.Cell(i, 1)
    ..the wrong way around (you are currently putting the value into Excel).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width