Hi,
I know there has been quite some discusion about this, but i found nothing helpful.
I want to export data on datagrid to excel in VB6 and i am in hurry...
i used the following code which works in office xp, but not in office 97 - Error 1004.
can you please tell me what i am doing wrong or give me any new idea/code!
**
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
'If IsNull(rs!excelfile) Then
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
rsSRRC_all_SIT_EUR.MoveFirst
I = 0
While Not rsSRRC_all_SIT_EUR.EOF
I = I + 1
For j = 0 To rsSRRC_all_SIT_EUR.Fields.Count - 1
xlSheet.Cells(I + 1, j + 1).Value = rsSRRC_all_SIT_EUR.Fields(j).Value
Next j
rsSRRC_all_SIT_EUR.MoveNext
Wend
End Sub
**
Thank you very much (-:
I know there has been quite some discusion about this, but i found nothing helpful.
I want to export data on datagrid to excel in VB6 and i am in hurry...
i used the following code which works in office xp, but not in office 97 - Error 1004.
can you please tell me what i am doing wrong or give me any new idea/code!
**
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
'If IsNull(rs!excelfile) Then
Set xlApp = New Excel.Application
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets(1)
rsSRRC_all_SIT_EUR.MoveFirst
I = 0
While Not rsSRRC_all_SIT_EUR.EOF
I = I + 1
For j = 0 To rsSRRC_all_SIT_EUR.Fields.Count - 1
xlSheet.Cells(I + 1, j + 1).Value = rsSRRC_all_SIT_EUR.Fields(j).Value
Next j
rsSRRC_all_SIT_EUR.MoveNext
Wend
End Sub
**
Thank you very much (-: