Results 1 to 38 of 38

Thread: something color with MSFlexGrid

Threaded View

  1. #17
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: something color with MSFlexGrid

    Here is another fast exporting to excel without looping through cells. It's a basic copy and paste. Good for exporting thousands of records.

    Fast Export Flexgrid to Excel

    Code:
    Private Sub cmdExportToExcel_Click()
    Dim xls As Excel.Application
    
    Set xls = New Excel.Application
    
    xls.Workbooks.Open (App.Path & "\Template.xls")
    
    xls.Visible = True
    
    'select all
    With MSFlexGrid1
        .Visible = False
        .Row = 0  'will depend on the user
        .Col = 1  'will depend on the user
        .RowSel = .Rows - 1
        .ColSel = .Cols - 1
        .TopRow = 1
        .Visible = True
    End With
        Clipboard.Clear
        'copy to clipboard
        Clipboard.SetText MSFlexGrid1.Clip
        'paste to excel
        xls.ActiveSheet.Paste
        Set xls = Nothing
    End Sub
    At first I was using Hack's code, but exporting thousands of records is a bit slow, I experimented if copy paste was possible and it was.
    Last edited by zynder; Aug 25th, 2007 at 06:50 PM. Reason: added Set xls = Nothing

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