By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,426 Members | 1,729 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,426 IT Pros & Developers. It's quick & easy.

How to export datagrid data on vb6 to excel

P: 5
Hi,

I want help with my problem.

How can i export datagrid data that comes from a ms sql server 2005 and will be going to ms excel..

Vbdude...

P.S. Please Help me!!!
Apr 2 '08 #1
Share this Question
Share on Google+
3 Replies


debasisdas
Expert 5K+
P: 8,127
what have you tried ?

are you struck some where in the code ?
Apr 2 '08 #2

P: 5
i try this one but I dont have any adodc
-----------------------------------------------------------------------
Private Sub btn_export_Click(Index As Integer)
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Dim j As Integer
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)
On Error GoTo errcode
With oBook.Worksheets("sheet1").Rows(1)
.Font.Bold = True
For j = 0 To DataGrid1.Columns.count - 1
Worksheets("sheet1").Cells(1, j + 1).Value = DataGrid1.Columns(j).Caption
Next j
End With
oSheet.Range("A2").CopyFromRecords Adodc1.Recordset
oBook.Open
oBook.SaveAs
oExcel.Quit
Exit Sub
errcode:
MsgBox Err.Description, , Err.Source

End Sub


the error is "Object doesn't support this property or method"
Apr 2 '08 #3

P: 5
i have declared rsEmployee as ADODB.Recordset

what should be the alternative to the adodc1.recordset?

ow.. they dont have any data to excel...

thank you for the reply and advance
Apr 2 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.