Visual Basic 6.0 Datagrid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charmagne
    New Member
    • Mar 2007
    • 2

    #1

    Visual Basic 6.0 Datagrid

    I have completed my development using a Datagrid in VB6. I need the users to be able to select all of the rows and columns (that were returned and displayed in the grid) so they can copy them to excel. At present, I can select each column by holding down the shift key to get all the columns, but I can not get the data to copy and paste into excel. Please help... thx
  • samycbe
    New Member
    • Feb 2007
    • 83

    #2
    you can convert files from grid to excel by the following steps

    1 add a microsoft excel library reference
    2 declare the following
    Dim a As New Excel.Applicati on
    Dim B As New Excel.Workbook

    3. on a command click write
    Set a = New Excel.Applicati on
    Set B = a.Workbooks.Add

    4. and in a loop write

    a.cells(i,j) = grid1.textmatri x(i,j)

    5 thats it

    Comment

    • charmagne
      New Member
      • Mar 2007
      • 2

      #3
      This response worked great!!! thx.....

      Now, I have a NEW PROBLEM.

      I had to change my project references from Microsoft ActiveX Data Objects 2.0 Library to the Microsoft ActiveX Data Objects 2.1 Library and my syntax for the database connection no longer works:

      Set conn1 = New ADODB.Connectio n
      strConn = "DSN=READ;UID=M e;PWD=MeMeMe;SE RVER=read_serv; "
      conn1.Execute strConn

      The code blows up on the third line with the error: Runtime error '3704' operation is not allowed when the object is closed.

      ANYBODY... SOMEBODY, pls help!

      Comment

      • Lavs
        New Member
        • Mar 2007
        • 16

        #4
        try this one...

        Set conn1 = New ADODB.Connectio n
        strConn = "DSN=READ;UID=M e;PWD=MeMeMe;SE RVER=read_serv; "
        conn1.connectio nstring = strConn
        conn1.open

        Comment

        Working...