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
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.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![]()




Reply With Quote