NO_CARRIER
asked on
Exporting VB6 Datagrid to MS-Excel
I want to export the contents of my datagrid to an excel document..
what i have is almost working, except it will only send over the visible information... (i.e if the contents of the datagrid is longer than 1 page, it will not send the information contained "off the page" to excel). In the code itselfI have "VisibleRows" in it... there is no other argument I can find for DataGrid ...
This is the code I'm using:
Dim Appli as New Excel.Application
Appli.SheetsInNewWorkbook = 1
Appli.Visible=True
Appli.Workbooks.Add
For i = 0 To DataGrid1.VisibleRows - 1
For j = 0 To DataGrid1.VisibleRows - 1
DataGrid1.Row = i
DataGrid1.Col = j
Appli.ActiveSheet.cells(i + 1, j + 1).Value = DataGrid1.Text
Next
Next
what i have is almost working, except it will only send over the visible information... (i.e if the contents of the datagrid is longer than 1 page, it will not send the information contained "off the page" to excel). In the code itselfI have "VisibleRows" in it... there is no other argument I can find for DataGrid ...
This is the code I'm using:
Dim Appli as New Excel.Application
Appli.SheetsInNewWorkbook = 1
Appli.Visible=True
Appli.Workbooks.Add
For i = 0 To DataGrid1.VisibleRows - 1
For j = 0 To DataGrid1.VisibleRows - 1
DataGrid1.Row = i
DataGrid1.Col = j
Appli.ActiveSheet.cells(i + 1, j + 1).Value = DataGrid1.Text
Next
Next
ASKER
hmm... I can't get it to export the complete datagrid.. only visible cells.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
points to emoreau
For intRow = 0 To .ApproxCount - 1
'Some stuff here...
'Incrémente la ligne (ne surtout pas enlever le "On error...")
On Error Resume Next
.Row = .Row + 1
On Error GoTo 0
Next intRow