Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    My first project vb and excel... (6.0)

    is this the correct way to cicling recordset in excel file or existis other way:
    Option Explicit
    Sub MAIN()

    Dim RSXls As New ADODB.Recordset
    Dim CONN As ADODB.Connection
    Dim PercorsoNome, TEST1 As String
    Dim RIGA As Long
    RIGA = 0
    Set CONN = New ADODB.Connection
    PercorsoNome = "E:MACROLOOP_DISTINCT_SQL_TABLE.xls"

    With CONN
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    .ConnectionString = "Data Source=" & PercorsoNome & ";" & _
    "Extended Properties=Excel 8.0;"
    .Open
    End With

    RSXls.Open "SELECT * FROM [NO_DUPLICATI$]", CONN, adOpenStatic

    Do Until RSXls.EOF
    TEST1 = RSXls(0)
    RIGA = RIGA + 1
    RSXls.MoveNext
    Loop

    RSXls.Close
    CONN.Close

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: My first project vb and excel... (6.0)

    Using ADO is one possibility. It works well.

    You could also use Automation, i.e. open Excel (invisibly) from VB6, and use Excel VBA from your VB6 application. See Automating Excel from VB 6.0 - Xtreme Visual Basic Talk

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: My first project vb and excel... (6.0)

    ok Teacher, have see into the link...Great!
    But for me importat is to process bigest numbers of cells and line in a sheet, ADO is a good way, or existis a other fasted method?

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: My first project vb and excel... (6.0)

    ADO is an efficient way of processing data in an Excel sheet, as long as they are stored in table format.

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: My first project vb and excel... (6.0)

    Good... tks.

Posting Permissions

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