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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

export data from vb datagrid to excel worksheet

Status
Not open for further replies.

goilaswati

Programmer
Mar 3, 2003
20
IN
i have this problem that i want to export my data of
datagrid to excel worksheet and i use the following code
i just write this code to load event of the form
firstly consider the code
Private Sub Form_Load()
Dim excel_app As New Excel.Application
Dim excel_sheet As New Excel.Worksheet
Dim row As Long
Dim rs As New ADODB.Recordset
Dim statement As String
Dim i As Integer
Set excel_app = CreateObject("Excel.Application")
excel_app.Visible = True
rs.CursorLocation = adUseClient

rs.Open "select * from weeklyitem", db, adOpenDynamic, adLockOptimistic
' MsgBox rs.Fields(1)

excel_sheet.Cells(1, 1) = rs.Fields(1).Value
' For i = 1 To rs.Fields.Count - 1
' excel_sheet.Cells(1, i) = rs.Fields(i).Name
' Next i
' row = 2
' Do While Not rs.EOF
' For i = 1 To rs.Fields.Count - 1
' excel_sheet.Cells(row, i) = rs.Fields(i).Value
' Next i
'
' row = row + 1
' rs.MoveNext
' Loop
rs.Close
End Sub


now sir i have see a error msg
that "class does not support automation or does not
support expected interface"

plz tell me what i do
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top