Results 1 to 2 of 2

Thread: export grid content to excel - reprise

  1. #1

    Thread Starter
    Addicted Member pardede's Avatar
    Join Date
    Jan 2000
    Posts
    232
    ok i have asked this once before but i seem to lost that thread so here goes again:

    I need to export the contents of a datagrid/dbgrid to excel, does anyone know how to do this quick (without having to loop thru the rows and cols)?

  2. #2
    Addicted Member
    Join Date
    Mar 2000
    Location
    Netherlands
    Posts
    128

    Hope this will do

    This is what i used once in a project i hope it is usefull




    Dim FS
    Dim Book
    'set up dialog box
    Dialog.Flags = &H4006
    Dialog.DialogTitle = DialogTitle.Caption
    Dialog.CancelError = True
    Dialog.InitDir = "C:\"
    Dialog.DefaultExt = "csv"
    Dialog.ShowSave
    FS = ";"

    Open Dialog.FileName For Output Shared As #1

    Print #1, "DATA"
    With Data1.Recordset
    Book = .Bookmark
    .MoveFirst
    Do Until .EOF
    Print #1, !Field1; FS; !Field2
    .MoveNext
    Loop
    .Bookmark = Book
    End With

    Close 1


    ASTERIX

    Remember Programmers don't sleep

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