Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export datagrid to excel - office 97

Status
Not open for further replies.

wtina

IS-IT--Management
Jul 1, 2003
9
SI
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 (-:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top